forked from delimitrou/DeathStarBench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Push SocialNetwork | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- 'socialNetwork/**' | ||
|
||
env: | ||
IMAGE_BASE_NAME: 'deathstarbench/social-network-microservices' | ||
REPO_PATH: 'socialNetwork' | ||
TAG_PREFIX: 'socialNetwork' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: master | ||
fetch-depth: 0 | ||
- name: Login to ACR | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_REGISTRY_LOGIN }} | ||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | ||
- name: Build docker image | ||
run: docker build -f "${{ env.REPO_PATH }}/Dockerfile" -t ${{ env.IMAGE_BASE_NAME }} ${{ env.REPO_PATH }} | ||
- name: Calculate new version | ||
id: new-version | ||
uses: codacy/[email protected] | ||
with: | ||
prefix: "${{ env.TAG_PREFIX }}-" | ||
log-paths: "${{ env.REPO_PATH }}/" | ||
if: github.ref == 'refs/heads/master' | ||
- name: Create tag | ||
uses: actions/github-script@v5 | ||
with: | ||
script: | | ||
github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: 'refs/tags/${{ steps.new-version.outputs.VERSION }}', | ||
sha: context.sha | ||
}) | ||
- name: Retrieve version number | ||
run: TEMP=${{ steps.new-version.outputs.VERSION }} && echo VERSION_NUMBER=${TEMP#*-} >> $GITHUB_ENV | ||
- name: Create image full name | ||
run: echo "IMAGE_ID=${{ env.IMAGE_BASE_NAME }}:${{ env.VERSION_NUMBER }}" >> $GITHUB_ENV | ||
- name: Tag image | ||
run: docker tag ${{ env.IMAGE_BASE_NAME }} ${{ env.IMAGE_ID }} | ||
- name: Push docker image | ||
run: docker push ${{ env.IMAGE_ID }} | ||
- name: Tag image as latest | ||
run: docker tag ${{ env.IMAGE_BASE_NAME }} ${{ env.IMAGE_BASE_NAME }}:latest | ||
- name: Push latest | ||
run: docker push ${{ env.IMAGE_BASE_NAME }}:latest |