From 707bab51c191196dfdb6a0c5172ec1e65ca30e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Michalski?= Date: Mon, 20 Jun 2022 23:29:27 +0200 Subject: [PATCH] Create socialnetwork-push.yaml --- .github/workflows/socialnetwork-push.yaml | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/socialnetwork-push.yaml diff --git a/.github/workflows/socialnetwork-push.yaml b/.github/workflows/socialnetwork-push.yaml new file mode 100644 index 000000000..407ee85e6 --- /dev/null +++ b/.github/workflows/socialnetwork-push.yaml @@ -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/git-version@2.4.0 + 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