From 9723a11d26eaac78382c91bbb0e1fa3bacdacdcb Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 10 Dec 2022 12:11:58 +0100 Subject: [PATCH] ci: updated actions and improved performance (#1582) --- .github/workflows/master-push.yml | 6 +++--- .github/workflows/pull-request-update.yml | 9 ++++++--- .github/workflows/tagged-commit.yml | 4 ++-- build/Dockerfile | 9 ++++++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/master-push.yml b/.github/workflows/master-push.yml index 4911368029..a618748598 100644 --- a/.github/workflows/master-push.yml +++ b/.github/workflows/master-push.yml @@ -48,8 +48,8 @@ jobs: GIT_BRANCH=master GIT_COMMITTED_AT=${{ env.TIME }} CC_TEST_REPORTER_ID=${{ secrets.CODE_CLIMATE_ID }} - cache-from: type=registry,ref=aamdigital/ndb-server:cache - cache-to: type=registry,ref=aamdigital/ndb-server:cache,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max check-dependencies: runs-on: ubuntu-latest steps: @@ -62,7 +62,7 @@ jobs: with: args: --sarif-file-output=snyk.sarif - name: Upload result to GitHub Code Scanning - uses: github/codeql-action/upload-sarif@v1 + uses: github/codeql-action/upload-sarif@v2 with: sarif_file: snyk.sarif run-e2e-tests: diff --git a/.github/workflows/pull-request-update.yml b/.github/workflows/pull-request-update.yml index d7f6f9cf04..00ba261155 100644 --- a/.github/workflows/pull-request-update.yml +++ b/.github/workflows/pull-request-update.yml @@ -11,7 +11,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Get time of commit run: echo "TIME=$(git log -1 --pretty=format:%ct)" >> $GITHUB_ENV - - name: Build dev image and save it locally + - name: Run tests in Docker image uses: docker/build-push-action@v3 with: context: ./ @@ -25,7 +25,9 @@ jobs: GIT_BRANCH=${{ github.head_ref }} GIT_COMMITTED_AT=${{ env.TIME }} CC_TEST_REPORTER_ID=${{ secrets.CODE_CLIMATE_ID }} - cache-from: type=registry,ref=aamdigital/ndb-server:cache + BUILD=${{ false }} + cache-from: type=gha + cache-to: type=gha,mode=max deploy-prod-image: runs-on: ubuntu-latest steps: @@ -46,7 +48,8 @@ jobs: builder: ${{ steps.buildx.outputs.name }} push: true tags: aamdigital/ndb-server:pr-${{ github.event.number }} - cache-from: type=registry,ref=aamdigital/ndb-server:cache + cache-from: type=gha + cache-to: type=gha,mode=max - name: Deploy updated image uses: appleboy/ssh-action@master with: diff --git a/.github/workflows/tagged-commit.yml b/.github/workflows/tagged-commit.yml index 379b232209..03f33ebf64 100644 --- a/.github/workflows/tagged-commit.yml +++ b/.github/workflows/tagged-commit.yml @@ -27,8 +27,8 @@ jobs: builder: ${{ steps.buildx.outputs.name }} push: true tags: aamdigital/ndb-server:${{ env.TAG }} - cache-from: type=registry,ref=aamdigital/ndb-server:cache - cache-to: type=registry,ref=aamdigital/ndb-server:cache,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max build-args: | APP_VERSION=${{ env.TAG }} SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_TOKEN }} diff --git a/build/Dockerfile b/build/Dockerfile index d856a23226..f9c08dd949 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -16,10 +16,13 @@ COPY . . ARG APP_VERSION="UNKNOWN" RUN sed -i "s/appVersion: \".*\"/appVersion: \"$APP_VERSION\"/g" src/environments/environment*.ts -# Transform the xliff files to json so this does not have to be done on the client side -RUN node build/prepare-translation-files.js -RUN npm run build +# When set to false, no production build for the app is done +ARG BUILD=true +RUN if [ "$BUILD" = true ] ; then \ + node build/prepare-translation-files.js &&\ + npm run build ; fi + # When set to true, tests are run and coverage will be uploaded to CodeClimate ARG UPLOAD_COVERAGE=false