From 8901d3f334e13d1866cc0ead5f368febc2f979f2 Mon Sep 17 00:00:00 2001 From: jggoebel <86782124+jggoebel@users.noreply.github.com> Date: Fri, 13 Jan 2023 11:37:47 +0100 Subject: [PATCH] Tag latest image (#143) * Tag latest image * Run prettier --- .github/workflows/main.yaml | 71 +++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4a64214a..03a19e2d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -23,45 +23,46 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - - name: Checkout - uses: actions/checkout@master + - name: Checkout + uses: actions/checkout@master - - name: Setup node_modules cache - id: cache-nodemodules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - with: - # cache node_modules to improve performance dramatically - path: node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + - name: Setup node_modules cache + id: cache-nodemodules + uses: actions/cache@v3 + env: + cache-name: cache-node-modules + with: + # cache node_modules to improve performance dramatically + path: node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - name: Install deps - run: npm install + - name: Install deps + run: npm install - - name: Build - run: npm run build:prod + - name: Build + run: npm run build:prod - - name: Build - run: | - docker build -f cicd/Dockerfile -t $app_image:${GIT_COMMIT_SHORT_HASH:-dev} . + - name: Build + run: | + docker build -f cicd/Dockerfile -t $app_image:${GIT_COMMIT_SHORT_HASH:-dev} . - - name: Docker Login - if: fromJSON(env.should_push_image) - run: | - echo "${{ secrets.REGISTRY_PASSWORD }}" \ - | docker login -u "${{ secrets.REGISTRY_USER }}" --password-stdin + - name: Docker Login + if: fromJSON(env.should_push_image) + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" \ + | docker login -u "${{ secrets.REGISTRY_USER }}" --password-stdin - - name: Docker Push - if: fromJSON(env.should_push_image) - run: | - safe_ref=$(echo "${{ github.ref_name }}" | sed -e 's/[^a-zA-Z0-9\-\.]/-/g') - publish_tag=$app_image:$safe_ref - - docker tag $app_image:${GIT_COMMIT_SHORT_HASH:-dev} $publish_tag - docker push $publish_tag + - name: Docker Push + if: fromJSON(env.should_push_image) + run: | + safe_ref=$(echo "${{ github.ref_name }}" | sed -e 's/[^a-zA-Z0-9\-\.]/-/g') + publish_tag=$app_image:$safe_ref - - name: Docker Push Latest - if: fromJSON(env.should_tag_latest) - run: docker push $app_image:latest + docker tag $app_image:${GIT_COMMIT_SHORT_HASH:-dev} $publish_tag + docker push $publish_tag + + - name: Docker Push Latest + if: fromJSON(env.should_tag_latest) + run: | + docker tag $app_image:${GIT_COMMIT_SHORT_HASH:-dev} $app_image:latest + docker push $app_image:latest