From 0a80301970db8663d1750be6cc3d40fbc8e613f7 Mon Sep 17 00:00:00 2001 From: guidojw Date: Sat, 6 Nov 2021 17:56:12 +0100 Subject: [PATCH 01/18] feat(CI): Continuous Integration fix(CI): remove old maintainer command feat(CI): try setting maintainer anothe rway feat(CI): use load Docker image action from own repository feat(CI): remove actions directory feat(CI): link action to own repository test(CI): test caching fix(CI): correct variable interpolation test(CI): test caching feat(CI): scope cache by file test(CI): test caching fix(CI): also remove scope in publish job test(CI): remove scope fix(CI): undo ESLint matcher trigger test fix(Dockerfile): move maintainer label to top stage fix(CI): typo in variable name refactor(CI): rename Dockerfile.ci fix(CI): undo stylelint trigger test fix(CI): correct path to stylelint converter fix(CI): run both commands and fail if one fails feat(CI): retry stylelint problem matcher fix(CI): try fixing path fix(CI): try without tty fix(CI): revert stylelint trigger test changes test(CI): trigger ESLint fix(CI): don't add styleling matcher fix(CI): remove stylelint matcher related code fix(CI): try other path fix(CI): try fixing path fix(CI): change stylelint command to path fix(CI): set npm path test(CI): convert stylelint output in bin feat(CI): add stylelint problem matcher fix(CI): checkout code first fix(CI): try wrapping path in quotes fix(CI): change add matcher command feat(CI): use problem matchers instead fix(CI): remove fail-on-error test(CI): remove level fix(CI): readd filter mode and change level to warning fix(CI): remove filter mode test(CI): test if reviewdog works feat(CI): change reviewdog filter to no filter fix(CI): add checkout code action to hopefully fix reviewdog error fix(CI): put eslint sed pattern in quotes fix(CI): use sed again for eslint output fix(CI): use grep to find rdjson output fix(CI): try removing footer line with sed too fix(CI): simplify sed commands fix(CI): try scripts again but remove lines first fix(CI): call lint commands directly fix(CI): rename stylelint reviewdog fix(CI): decouple stylelint from lint command fix(CI): remove interactive terminal to try fix reviewdog fix(CI): try fixing lint command for ci in package feat(CI): setup reviewdog fix(CI): also run on PR synchronize test(CI): test Slack webhook test(CI): test Slack webhook test(CI): test webhook feat(CI): uncomment ref check for production image build fix(CI): remove cache mode fix(CI): also color test output feat(CI): try setting color feat(CI): try other cache mode fix(CI): fix image tag refactor(CI): remove metadata action fix(CI): typo in login action version feat(CI): use metadata action fix(CI): yml syntax error feat(CI): try publishing to GHCR fix(CI): test cache scopes fix(CI): scope cache feat(CI): add concurrency settings feat(CI): make upload optional fix(CI): fix if expression II fix(CI): fix if expression fix(CI): change built app name feat(CI): test building staging image feat(CI): support build args and add publish mock refactor(CI): move building to composite action feat(CI): add test step fix(CI): add tags to build-push action fix(CI): test if Docker Buildx fixes image loading fix(CI): correct image ls command fix(CI): try printing images fix(CI): use correct flag for docker load fix(CI): fix action and change output type feat(CI): test image loading feat(CI): test caching fix(CI): build Dockerfile feat(CI): test image building and caching using Buildx feat(CI): actually run lint and add test fix: remove emojis from step name refactor: rename docker-compose.buildkite.yml fix(CI): move checkout code out of step feat(CI): test Docker image building feat: add file refactor(CI): move problem matchers to own folder refactor(CI): update workflow file refactor(CI): move problem matchers to own folder refactor(CI): update workflow file --- .buildkite/pipeline.yml | 10 +- .eslintignore | 1 + .github/problem-matchers/eslint-stylish.json | 22 ++++ .github/problem-matchers/stylelint.json | 22 ++++ .github/workflows/continuous-integration.yml | 101 +++++++++++++++++++ Dockerfile | 4 +- Dockerfile.buildkite => Dockerfile.test | 0 bin/convert-stylelint-output.js | 18 ++++ docker-compose.buildkite.yml | 21 ---- package.json | 4 +- yarn.lock | 5 +- 11 files changed, 177 insertions(+), 31 deletions(-) create mode 100644 .github/problem-matchers/eslint-stylish.json create mode 100644 .github/problem-matchers/stylelint.json create mode 100644 .github/workflows/continuous-integration.yml rename Dockerfile.buildkite => Dockerfile.test (100%) create mode 100644 bin/convert-stylelint-output.js delete mode 100644 docker-compose.buildkite.yml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5842cca84..573a4e122 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -3,7 +3,7 @@ steps: plugins: - docker-compose#v2.6.0: build: app - config: docker-compose.buildkite.yml + config: docker-compose.ci.yml - wait @@ -12,14 +12,14 @@ steps: plugins: - docker-compose#v2.6.0: run: app - config: docker-compose.buildkite.yml + config: docker-compose.ci.yml - label: ":yarn: :eslint: Lint" command: "yarn lint" plugins: - docker-compose#v2.6.0: run: app - config: docker-compose.buildkite.yml + config: docker-compose.ci.yml - wait @@ -32,7 +32,7 @@ steps: password-env: DOCKER_PASSWORD - docker-compose#v2.6.0: push: app-staging:docker.csvalpha.nl/amber-ui:staging - config: docker-compose.buildkite.yml + config: docker-compose.ci.yml - label: ":docker: Build+Push `:production` image" branches: "master" @@ -43,7 +43,7 @@ steps: password-env: DOCKER_PASSWORD - docker-compose#v2.6.0: push: app-production:docker.csvalpha.nl/amber-ui:latest - config: docker-compose.buildkite.yml + config: docker-compose.ci.yml - block: "Deploy this stage" branches: "master staging" diff --git a/.eslintignore b/.eslintignore index 72df37307..8c71bf839 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,7 @@ # unconventional js /blueprints/*/files/ /vendor/ +/bin/ # compiled output /dist/ diff --git a/.github/problem-matchers/eslint-stylish.json b/.github/problem-matchers/eslint-stylish.json new file mode 100644 index 000000000..cc2067d06 --- /dev/null +++ b/.github/problem-matchers/eslint-stylish.json @@ -0,0 +1,22 @@ +{ + "problemMatcher": [ + { + "owner": "eslint-stylish", + "pattern": [ + { + "regexp": "^/app/([^\\s].*)$", + "file": 1 + }, + { + "regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$", + "line": 1, + "column": 2, + "severity": 3, + "message": 4, + "code": 5, + "loop": true + } + ] + } + ] +} diff --git a/.github/problem-matchers/stylelint.json b/.github/problem-matchers/stylelint.json new file mode 100644 index 000000000..8c564b49f --- /dev/null +++ b/.github/problem-matchers/stylelint.json @@ -0,0 +1,22 @@ +{ + "problemMatcher": [ + { + "owner": "stylelint", + "pattern": [ + { + "regexp": "^([^\\s].*)$", + "file": 1 + }, + { + "regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$", + "line": 1, + "column": 2, + "severity": 3, + "message": 4, + "code": 5, + "loop": true + } + ] + } + ] +} diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 000000000..ab8732c8a --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,101 @@ +name: Continuous Integration + +on: + push: + branches: [staging, master] + pull_request: + +concurrency: + group: ci-${{ github.ref_name }} + cancel-in-progress: true + +env: + APP_ID: 152323 + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build test image + uses: guidojw/actions/build-docker-image@v1 + with: + file: Dockerfile.test + name: app + + lint: + name: Lint + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Add problem matchers + run: | + echo "::add-matcher::.github/problem-matchers/eslint-stylish.json" + echo "::add-matcher::.github/problem-matchers/stylelint.json" + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Load test image + uses: guidojw/actions/load-docker-image@v1 + with: + name: app + + - name: Lint + # Convert output of stylelint so that the problem matcher can match it correctly. + run: | + EXIT_STATUS=0 + docker run app yarn ci:eslint || EXIT_STATUS=$? + node bin/convert-stylelint-output.js "$(docker run app yarn ci:stylelint)" || EXIT_STATUS=$? + exit $EXIT_STATUS + + test: + name: Test + runs-on: ubuntu-latest + needs: build + steps: + - name: Load test image + uses: guidojw/actions/load-docker-image@v1 + with: + name: app + + - name: Test + run: | + docker run -t app yarn test + + update_check_run: + name: Update Check Run + runs-on: ubuntu-latest + needs: [build, lint, test] + if: github.event_name == 'workflow_dispatch' && github.workflow == 'Continuous Integration' && always() + steps: + - name: Get conclusion + id: get_conclusion + env: + RESULTS: ${{ join(needs.*.result, ' ') }} + run: | + for RESULT in $RESULTS; do + if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then + echo '::set-output name=conclusion::'$RESULT + exit + fi + done + echo '::set-output name=conclusion::success' + + - name: Update Continuous Integration check run + uses: guidojw/actions/update-check-run@v1 + with: + app_id: ${{ env.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + sha: ${{ needs.merge.outputs.sha }} + name: Continuous Integration + conclusion: ${{ steps.get_conclusion.outputs.conclusion }} + details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/Dockerfile b/Dockerfile index 8f61cb720..23cf1a23c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM madnificent/ember:3.17.0 as ember -MAINTAINER C.S.V. Alpha ARG DEPLOY_TARGET='production' ARG BUILD_HASH='unknown' @@ -11,7 +10,10 @@ RUN yarn install --ignore-engines COPY . /app RUN DEPLOY_TARGET=$DEPLOY_TARGET BUILD_HASH=$BUILD_HASH ember build --environment=production + FROM nginx:1.17-alpine +LABEL maintainer="C.S.V. Alpha " + RUN rm /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/conf.d/app.conf COPY --from=ember /app/dist /usr/share/nginx/html diff --git a/Dockerfile.buildkite b/Dockerfile.test similarity index 100% rename from Dockerfile.buildkite rename to Dockerfile.test diff --git a/bin/convert-stylelint-output.js b/bin/convert-stylelint-output.js new file mode 100644 index 000000000..e3916ebc4 --- /dev/null +++ b/bin/convert-stylelint-output.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node +'use strict' + +/** + * Converts stylelint output to problem matcher compatible output. + * Usage: node convert-stylelint-output.js "$(yarn stylelint)" + */ + +const input = process.argv.slice(2)[0] + +// https://github.com/stylelint/stylelint/blob/76f6fe07650c0adde5a058600f08d9f4cec71599/lib/formatters/stringFormatter.js#L25 +const output = input + .replace(/\u2139/g, 'info') + .replace(/\u26A0/g, 'warning') + .replace(/\u2716/g, 'error') + .replace(/\u2714/g, 'success') + +console.log(output) diff --git a/docker-compose.buildkite.yml b/docker-compose.buildkite.yml deleted file mode 100644 index a7fb15733..000000000 --- a/docker-compose.buildkite.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: '3' - -services: - app: - build: - context: . - dockerfile: Dockerfile.buildkite - - app-production: - build: &production-build - context: . - dockerfile: Dockerfile - args: - - BUILD_HASH=${BUILDKITE_COMMIT} - - app-staging: - build: - <<: *production-build - args: - - DEPLOY_TARGET=staging - - BUILD_HASH=${BUILDKITE_COMMIT} diff --git a/package.json b/package.json index fe3ad9c4d..cc1b3a5eb 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,9 @@ "lint:hbs": "ember-template-lint .", "start": "ember serve", "stylefix": "stylelint 'app/**/*.scss' --fix", - "test": "ember test" + "test": "ember test", + "ci:eslint": "eslint 'app/**/*.js'", + "ci:stylelint": "stylelint 'app/**/*.scss'" }, "devDependencies": { "@babel/plugin-proposal-optional-chaining": "^7.14.5", diff --git a/yarn.lock b/yarn.lock index 734a0beb8..bfa6b7615 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1773,7 +1773,7 @@ integrity sha512-3sQlpEjOXt03sId8ZYGWjm6SdQaR78Ppa6LwLon76kYsDM8J2hRXY1Zcpt1rKTSuOyXs/0Pc5+ri1MNfJKD3DA== dependencies: "@embroider/macros" "0.39.1" - broccoli-funnel "github:ef4/broccoli-funnel#c70d060076e14793e8495571f304a976afc754ac" + broccoli-funnel ef4/broccoli-funnel#c70d060076e14793e8495571f304a976afc754ac ember-cli-babel "^7.23.1" "@eslint/eslintrc@^0.4.3": @@ -4565,9 +4565,8 @@ broccoli-funnel@^3.0.5, broccoli-funnel@^3.0.8: minimatch "^3.0.0" walk-sync "^2.0.2" -"broccoli-funnel@github:ef4/broccoli-funnel#c70d060076e14793e8495571f304a976afc754ac": +broccoli-funnel@ef4/broccoli-funnel#c70d060076e14793e8495571f304a976afc754ac: version "2.0.2-ef4.0" - uid c70d060076e14793e8495571f304a976afc754ac resolved "https://codeload.github.com/ef4/broccoli-funnel/tar.gz/c70d060076e14793e8495571f304a976afc754ac" dependencies: array-equal "^1.0.0" From b47c16bb211a33b40ff2f2feb0f732986f4ef1a7 Mon Sep 17 00:00:00 2001 From: guidojw Date: Thu, 11 Nov 2021 02:39:05 +0100 Subject: [PATCH 02/18] feat(CD): Continuous Delivery feat(CD): add workflow fix(CI): read correct event input and fix if fix(CD): point to feature branch feat(CD): begin implementation test(CI): more ifs tests test(CI): test ifs test(CI): try other status check test(CI): test needs + if feat(CI): add publish image workflow refactor: update publish image workflow file feat(CI): add publish image workflow test(CI): test needs + if test(CI): try other status check test(CI): test ifs test(CI): more ifs tests feat(CD): begin implementation fix(CD): point to feature branch fix(CI): read correct event input and fix if feat(CD): add workflow refactor: update publish image workflow file --- .github/workflows/continuous-delivery.yml | 193 +++++++++++++++++++ .github/workflows/continuous-integration.yml | 2 +- .github/workflows/publish-image.yml | 132 +++++++++++++ 3 files changed, 326 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/continuous-delivery.yml create mode 100644 .github/workflows/publish-image.yml diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml new file mode 100644 index 000000000..679c90d7c --- /dev/null +++ b/.github/workflows/continuous-delivery.yml @@ -0,0 +1,193 @@ +name: Continuous Delivery + +on: + workflow_dispatch: + inputs: + merge: + description: Merge staging into master first? (y/N) + required: false + default: 'n' + +concurrency: + group: cd-${{ github.ref_name }} + +env: + PROJECT_NAME: amber-ui + SENTRY_ORG: csvalpha + APP_ID: 152333 + +jobs: + branch_check: + name: Branch Check + runs-on: ubuntu-latest + steps: + - name: Validate branch + run: | + if [ $GITHUB_REF_NAME != 'staging' ] && [ $GITHUB_REF_NAME != 'master' ]; then + echo 'This workflow can only be run on branches staging and master.' + exit 1 + fi + + metadata: + name: Metadata + runs-on: ubuntu-latest + needs: branch_check + outputs: + has_diff: ${{ steps.get_metadata.outputs.has_diff }} + stage: ${{ steps.get_metadata.outputs.stage }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get metadata + id: get_metadata + env: + INPUT_MERGE: ${{ github.event.inputs.merge }} + run: | + if [ $GITHUB_REF_NAME = 'master' ]; then + if [ "${INPUT_MERGE,,}" = 'y' ]; then + git fetch origin staging + if ! git diff origin/master origin/staging --exit-code; then + echo '::set-output name=has_diff::true' + else + echo '::set-output name=has_diff::false' + fi + fi + + echo '::set-output name=stage::production' + else + echo '::set-output name=stage::staging' + fi + + merge: + name: Merge + runs-on: ubuntu-latest + needs: metadata + if: github.event.inputs.merge == 'y' + outputs: + sha: ${{ steps.get_sha.outputs.sha }} + steps: + - name: Validate inputs + env: + HAS_DIFF: ${{ fromJSON(needs.metadata.outputs.has_diff || false) }} + run: | + if [ $GITHUB_REF_NAME != 'master' ]; then + echo 'Can only merge when the workflow target branch is master.' + exit 1 + fi + + if ! $HAS_DIFF; then + echo 'There is no diff so a merge is not necessary, skipping next steps.' + fi + + - name: Checkout code + if: fromJSON(needs.metadata.outputs.has_diff) + uses: actions/checkout@v2 + + - name: Run merge + if: fromJSON(needs.metadata.outputs.has_diff) + uses: devmasx/merge-branch@v1.4.0 + with: + type: now + from_branch: staging + target_branch: master + github_token: ${{ github.token }} + + - name: Get merge commit SHA + id: get_sha + if: fromJSON(needs.metadata.outputs.has_diff) + run: | + git fetch origin master + echo '::set-output name=sha::'$(git rev-parse origin/master) + + publish: + name: Publish + needs: [metadata, merge] + if: fromJSON(needs.metadata.outputs.has_diff) + uses: csvalpha/amber-ui/.github/workflows/publish-image.yml@staging + with: + sha: ${{ needs.merge.outputs.sha }} + + deploy: + name: Deploy + runs-on: ubuntu-latest + needs: [metadata, merge, publish] + if: | + (github.ref_name == 'staging' || github.ref_name == 'master') && ((github.ref_name == 'master' && + github.event.inputs.merge == 'y' && fromJSON(needs.metadata.outputs.has_diff) && success()) || + ((github.event.inputs.merge != 'y' || !fromJSON(needs.metadata.outputs.has_diff)) && !cancelled())) + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ needs.merge.outputs.sha }} + fetch-depth: 0 + + - name: Start deployment + uses: bobheadxi/deployments@v0.4.3 + id: start_deployment + with: + step: start + token: ${{ secrets.GITHUB_TOKEN }} + env: ${{ needs.metadata.outputs.stage }} + + - name: Deploy + uses: appleboy/ssh-action@v0.1.4 + env: + STAGE: ${{ needs.metadata.outputs.stage }} + with: + host: csvalpha.nl + username: github-actions + key: ${{ secrets.SSH_PRIVATE_KEY }} + envs: PROJECT_NAME,STAGE + script: | + cd /opt/docker/$PROJECT_NAME/$STAGE + docker-compose pull + docker-compose up -d + + - name: Finalize Sentry release + uses: getsentry/action-release@v1 + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_PROJECT: ${{ env.PROJECT_NAME }} + with: + environment: ${{ needs.metadata.outputs.stage }} + + - name: Finish deployment + uses: bobheadxi/deployments@v0.4.3 + if: steps.start_deployment.conclusion == 'success' && always() + with: + step: finish + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + deployment_id: ${{ steps.start_deployment.outputs.deployment_id }} + env_url: https://www.google.com + + update_check_run: + name: Update Check Run + runs-on: ubuntu-latest + needs: [branch_check, metadata, merge, publish, deploy] + if: (github.ref_name == 'staging' || github.ref_name == 'master') && always() + steps: + - name: Get conclusion + id: get_conclusion + env: + RESULTS: ${{ join(needs.*.result, ' ') }} + run: | + for RESULT in $RESULTS; do + if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then + echo '::set-output name=conclusion::'$RESULT + exit + fi + done + echo '::set-output name=conclusion::success' + + - name: Update Continuous Delivery check run + uses: guidojw/actions/update-check-run@v1 + with: + app_id: ${{ env.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + sha: ${{ needs.merge.outputs.sha }} + name: Continuous Delivery + conclusion: ${{ steps.get_conclusion.outputs.conclusion }} + details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ab8732c8a..e0df876f6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true env: - APP_ID: 152323 + APP_ID: 152333 jobs: build: diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml new file mode 100644 index 000000000..dfde506c5 --- /dev/null +++ b/.github/workflows/publish-image.yml @@ -0,0 +1,132 @@ +name: Publish Image + +on: + push: + branches: [staging, master] + workflow_call: + inputs: + sha: + required: false + type: string + workflow_dispatch: + +env: + PROJECT_NAME: amber-ui + REGISTRY_URL: ghcr.io + SENTRY_ORG: csvalpha + APP_ID: 152333 + +jobs: + metadata: + name: Metadata + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.get_metadata.outputs.tag }} + build_args: ${{ steps.get_metadata.outputs.build_args }} + steps: + - name: Get metadata + id: get_metadata + run: | + if [ $GITHUB_REF_NAME = 'master' ]; then + echo '::set-output name=tag::latest' + else + echo '::set-output name=tag::'$GITHUB_REF_NAME + fi + + if [ $GITHUB_REF_NAME = 'staging' ] || [ $GITHUB_REF_NAME = 'master' ]; then + BUILD_ARGS='BUILD_HASH='$GITHUB_SHA + if [ $GITHUB_REF_NAME = 'staging' ]; then + BUILD_ARGS+=$'\nDEPLOY_TARGET=staging' + fi + BUILD_ARGS=${BUILD_ARGS//$'\n'/'%0A'} + echo '::set-output name=build_args::'$BUILD_ARGS + + if [ $GITHUB_REF_NAME = 'master' ]; then + echo '::set-output name=stage::production' + else + echo '::set-output name=stage::staging' + fi + fi + + publish: + name: Publish + runs-on: ubuntu-latest + needs: metadata + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ inputs.sha }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY_URL }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + id: build_push_image + uses: docker/build-push-action@v2 + with: + push: true + context: . + build-args: ${{ needs.metadata.outputs.build_args }} + cache-from: type=gha,scope=main + cache-to: type=gha,scope=main + tags: | + ${{ env.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.PROJECT_NAME }}:${{ + needs.metadata.outputs.tag }} + + - name: Get sourcemaps from image + if: | + github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && + github.workflow == 'Continuous Delivery') + env: + IMAGE_NAME: ${{ fromJSON(steps.build_push_image.outputs.metadata)['image.name'] }} + run: | + docker cp $(docker create $IMAGE_NAME):/usr/share/nginx/html/assets/. sourcemaps + + - name: Create Sentry release + if: | + github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && + github.workflow == 'Continuous Delivery') + uses: getsentry/action-release@v1 + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_PROJECT: ${{ env.PROJECT_NAME }} + with: + environment: ${{ needs.metadata.outputs.stage }} + finalize: false + sourcemaps: sourcemaps + + update_check_run: + name: Update Check Run + runs-on: ubuntu-latest + needs: [metadata, publish] + if: github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image' && always() + steps: + - name: Get conclusion + id: get_conclusion + env: + RESULTS: ${{ join(needs.*.result, ' ') }} + run: | + for RESULT in $RESULTS; do + if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then + echo '::set-output name=conclusion::'$RESULT + exit + fi + done + echo '::set-output name=conclusion::success' + + - name: Update Publish Image check run + uses: guidojw/actions/update-check-run@v1 + with: + app_id: ${{ env.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + name: Publish Image + conclusion: ${{ steps.get_conclusion.outputs.conclusion }} + details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} From 096bf0217a82605f9320413153b183251938b3be Mon Sep 17 00:00:00 2001 From: guidojw Date: Tue, 23 Nov 2021 23:59:35 +0100 Subject: [PATCH 03/18] chore: update README chore: add badges to README chore: update README chore: add badges to README --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f125547b..be3693555 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ Alpha AMBER UI =============== -[![Build status](https://badge.buildkite.com/42748a5ed2c1c77c1dd974c497f0f39eaf39d782a289d19a8e.svg)](https://buildkite.com/csv-alpha/amber-ui) +[![Continuous Integration](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-integration.yml) +[![Continuous Delivery](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-delivery.yml/badge.svg)](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-delivery.yml) ## Prerequisites @@ -77,7 +78,12 @@ For auto fix run ### Deploying -Deploying is done via buildkite. To do a deploy push to GitHub and click on the 'Deploy this step' button in buildkite to finish the deploy. +Deployments are done using GitHub Actions. To deploy a branch, follow the following steps: + +* Go to the Continuous Delivery [workflow page](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-delivery.yml). +* Open the "Run workflow" modal. +* Choose a branch and if you want to merge the changes on the staging branch into the master branch (only possible when the branch chosen in previous step is master). +* Click the green button "Run workflow". ## Further Reading / Useful Links From 6769a5d2a189be7c91ea31af000a081b54b06bb2 Mon Sep 17 00:00:00 2001 From: guidojw Date: Tue, 23 Nov 2021 23:59:43 +0100 Subject: [PATCH 04/18] refactor: remove Buildkite configurations chore: remove last Buildkite occurences from code refactor: remove .buildkite directory chore: remove last Buildkite occurences from code --- .buildkite/pipeline.yml | 63 ----------------------------------------- .buildkite/release.sh | 7 ----- .buildkite/sentry.sh | 9 ------ .buildkite/slack.sh | 8 ------ Dockerfile.test | 2 +- testem.js | 2 +- 6 files changed, 2 insertions(+), 89 deletions(-) delete mode 100644 .buildkite/pipeline.yml delete mode 100644 .buildkite/release.sh delete mode 100644 .buildkite/sentry.sh delete mode 100644 .buildkite/slack.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index 573a4e122..000000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,63 +0,0 @@ -steps: - - label: ":docker: Build test image" - plugins: - - docker-compose#v2.6.0: - build: app - config: docker-compose.ci.yml - - - wait - - - label: ":yarn: Test" - command: "yarn test" - plugins: - - docker-compose#v2.6.0: - run: app - config: docker-compose.ci.yml - - - label: ":yarn: :eslint: Lint" - command: "yarn lint" - plugins: - - docker-compose#v2.6.0: - run: app - config: docker-compose.ci.yml - - - wait - - - label: ":docker: Build+Push `:staging` image" - branches: "staging" - plugins: - - docker-login#v2.0.1: - server: docker.csvalpha.nl - username: buildkite - password-env: DOCKER_PASSWORD - - docker-compose#v2.6.0: - push: app-staging:docker.csvalpha.nl/amber-ui:staging - config: docker-compose.ci.yml - - - label: ":docker: Build+Push `:production` image" - branches: "master" - plugins: - - docker-login#v2.0.1: - server: docker.csvalpha.nl - username: buildkite - password-env: DOCKER_PASSWORD - - docker-compose#v2.6.0: - push: app-production:docker.csvalpha.nl/amber-ui:latest - config: docker-compose.ci.yml - - - block: "Deploy this stage" - branches: "master staging" - - - label: 'Restarting service' - command: 'bash .buildkite/release.sh' - branches: "master staging" - - - wait - - - label: 'Inform Sentry' - command: 'bash .buildkite/sentry.sh' - branches: "master staging" - - - label: 'Inform Slack' - command: 'bash .buildkite/slack.sh' - branches: "master staging" diff --git a/.buildkite/release.sh b/.buildkite/release.sh deleted file mode 100644 index afa31a03d..000000000 --- a/.buildkite/release.sh +++ /dev/null @@ -1,7 +0,0 @@ -STAGE=$BUILDKITE_BRANCH -if [ "$STAGE" = "master" ]; then STAGE='production'; fi -if [ "$STAGE" = "production" ] || [ "$STAGE" = "staging" ]; then echo 'Deploying for stage' $STAGE; else echo 'Stage' $STAGE 'unknown.. skipping deploy'; exit 0; fi - -cd /opt/docker/amber-ui/$STAGE -docker-compose pull web -docker-compose up --build -d web diff --git a/.buildkite/sentry.sh b/.buildkite/sentry.sh deleted file mode 100644 index 86c366408..000000000 --- a/.buildkite/sentry.sh +++ /dev/null @@ -1,9 +0,0 @@ -STAGE=$BUILDKITE_BRANCH -if [ "$STAGE" = "master" ]; then STAGE='production'; fi -if [ "$STAGE" = "production" ] || [ "$STAGE" = "staging" ]; then echo 'Deploying for stage' $STAGE; else echo 'Stage' $STAGE 'unknown.. skipping deploy'; exit 0; fi - -curl -sSf -H 'Content-Type: application/json' \ - -H 'Authorization: Bearer '$SENTRY_API_TOKEN \ - --request POST \ - --data '{"version": "'"$(date)"'", "ref": "'"$BUILDKITE_COMMIT"'"}' \ - https://sentry.io/api/0/projects/csvalpha/amber-ui-$STAGE/releases/ diff --git a/.buildkite/slack.sh b/.buildkite/slack.sh deleted file mode 100644 index c2741d39c..000000000 --- a/.buildkite/slack.sh +++ /dev/null @@ -1,8 +0,0 @@ -STAGE=$BUILDKITE_BRANCH -if [ "$STAGE" = "master" ]; then STAGE='production'; fi -if [ "$STAGE" = "production" ] || [ "$STAGE" = "staging" ]; then echo 'Deploying for stage' $STAGE; else echo 'Stage' $STAGE 'unknown.. skipping deploy'; exit 0; fi - -curl -sSf --request POST \ - -H 'Content-type: application/json' \ - --data '{"username": "Buildkite deploy", "text": "Deploy for amber-ui '$STAGE' is finished"}' \ - $SLACK_URL diff --git a/Dockerfile.test b/Dockerfile.test index 5dacc82ef..ac0cec195 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -2,7 +2,7 @@ FROM madnificent/ember:3.17.0 as ember MAINTAINER C.S.V. Alpha ENV NODE_ENV=test -ENV BUILDKITE=true +ENV CI=true # Install chrome RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - diff --git a/testem.js b/testem.js index a2d30d2c2..89da2c57c 100644 --- a/testem.js +++ b/testem.js @@ -14,7 +14,7 @@ module.exports = { Chrome: { ci: [ // --no-sandbox is needed when running Chrome inside a container - process.env.BUILDKITE ? '--no-sandbox' : null, + process.env.CI ? '--no-sandbox' : null, '--headless', '--disable-dev-shm-usage', '--disable-software-rasterizer', From 02ee6567c9b758d66aad81c92c8e435165e6ae02 Mon Sep 17 00:00:00 2001 From: guidojw Date: Wed, 24 Nov 2021 00:20:47 +0100 Subject: [PATCH 05/18] feat: add workflow for cleaning up registry refactor: use repository owner from context instead of static feat: add workflow for cleaning up registry refactor: use repository owner from context instead of static --- .github/workflows/cleanup-registry.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/cleanup-registry.yml diff --git a/.github/workflows/cleanup-registry.yml b/.github/workflows/cleanup-registry.yml new file mode 100644 index 000000000..1fc72ee30 --- /dev/null +++ b/.github/workflows/cleanup-registry.yml @@ -0,0 +1,24 @@ +name: Cleanup Registry + +on: + schedule: + - cron: '0 0 * * 1' # https://crontab.guru/#0_0_*_*_1 + workflow_dispatch: + +env: + IMAGE_NAMES: amber-ui + +jobs: + cleanup: + name: Cleanup + runs-on: ubuntu-latest + steps: + - name: Delete old versions + uses: snok/container-retention-policy@v1 + with: + image-names: ${{ env.IMAGE_NAMES }} + cut-off: 2 days ago UTC + account-type: org + org-name: ${{ github.repository_owner }} + skip-tags: latest,staging + token: ${{ secrets.PAT }} From 81943f5580b74c615237cd55541b68f556d64668 Mon Sep 17 00:00:00 2001 From: guidojw Date: Wed, 24 Nov 2021 01:06:35 +0100 Subject: [PATCH 06/18] fix: also run Continuous Integration workflow after merge --- .github/workflows/continuous-delivery.yml | 12 ++++++++++-- .github/workflows/continuous-integration.yml | 9 +++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 679c90d7c..e5e76d678 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -100,6 +100,14 @@ jobs: git fetch origin master echo '::set-output name=sha::'$(git rev-parse origin/master) + continuous_integration: + name: Continuous Integration + needs: [metadata, merge] + if: fromJSON(needs.metadata.outputs.has_diff) + uses: csvalpha/amber-ui/.github/workflows/continuous-integration.yml@staging + with: + sha: ${{ needs.merge.outputs.sha }} + publish: name: Publish needs: [metadata, merge] @@ -111,7 +119,7 @@ jobs: deploy: name: Deploy runs-on: ubuntu-latest - needs: [metadata, merge, publish] + needs: [metadata, merge, continuous_integration, publish] if: | (github.ref_name == 'staging' || github.ref_name == 'master') && ((github.ref_name == 'master' && github.event.inputs.merge == 'y' && fromJSON(needs.metadata.outputs.has_diff) && success()) || @@ -166,7 +174,7 @@ jobs: update_check_run: name: Update Check Run runs-on: ubuntu-latest - needs: [branch_check, metadata, merge, publish, deploy] + needs: [branch_check, metadata, merge, continuous_integration, publish, deploy] if: (github.ref_name == 'staging' || github.ref_name == 'master') && always() steps: - name: Get conclusion diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e0df876f6..8016ec4b9 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -4,6 +4,11 @@ on: push: branches: [staging, master] pull_request: + workflow_call: + inputs: + sha: + required: false + type: string concurrency: group: ci-${{ github.ref_name }} @@ -19,6 +24,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + ref: ${{ inputs.sha }} - name: Build test image uses: guidojw/actions/build-docker-image@v1 @@ -33,6 +40,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + ref: ${{ inputs.sha }} - name: Add problem matchers run: | From ab7a33ec520405c5ddabf80067c04245c3737702 Mon Sep 17 00:00:00 2001 From: guidojw Date: Wed, 24 Nov 2021 01:08:12 +0100 Subject: [PATCH 07/18] fix: remove redundant Update Check Run job from CI --- .github/workflows/continuous-integration.yml | 32 -------------------- 1 file changed, 32 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8016ec4b9..eb514b111 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -14,9 +14,6 @@ concurrency: group: ci-${{ github.ref_name }} cancel-in-progress: true -env: - APP_ID: 152333 - jobs: build: name: Build @@ -79,32 +76,3 @@ jobs: - name: Test run: | docker run -t app yarn test - - update_check_run: - name: Update Check Run - runs-on: ubuntu-latest - needs: [build, lint, test] - if: github.event_name == 'workflow_dispatch' && github.workflow == 'Continuous Integration' && always() - steps: - - name: Get conclusion - id: get_conclusion - env: - RESULTS: ${{ join(needs.*.result, ' ') }} - run: | - for RESULT in $RESULTS; do - if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then - echo '::set-output name=conclusion::'$RESULT - exit - fi - done - echo '::set-output name=conclusion::success' - - - name: Update Continuous Integration check run - uses: guidojw/actions/update-check-run@v1 - with: - app_id: ${{ env.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - sha: ${{ needs.merge.outputs.sha }} - name: Continuous Integration - conclusion: ${{ steps.get_conclusion.outputs.conclusion }} - details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} From f634f9ad7cc3121f781c3dfab8d77fcc64206ae8 Mon Sep 17 00:00:00 2001 From: guidojw Date: Wed, 24 Nov 2021 19:01:59 +0100 Subject: [PATCH 08/18] fix: final fixes --- .github/workflows/continuous-delivery.yml | 12 ++++++------ .github/workflows/publish-image.yml | 9 +++------ docker-compose.yml | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index e5e76d678..56d9c99a1 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -108,8 +108,8 @@ jobs: with: sha: ${{ needs.merge.outputs.sha }} - publish: - name: Publish + publish_image: + name: Publish Image needs: [metadata, merge] if: fromJSON(needs.metadata.outputs.has_diff) uses: csvalpha/amber-ui/.github/workflows/publish-image.yml@staging @@ -119,7 +119,7 @@ jobs: deploy: name: Deploy runs-on: ubuntu-latest - needs: [metadata, merge, continuous_integration, publish] + needs: [metadata, merge, continuous_integration, publish_image] if: | (github.ref_name == 'staging' || github.ref_name == 'master') && ((github.ref_name == 'master' && github.event.inputs.merge == 'y' && fromJSON(needs.metadata.outputs.has_diff) && success()) || @@ -129,7 +129,6 @@ jobs: uses: actions/checkout@v2 with: ref: ${{ needs.merge.outputs.sha }} - fetch-depth: 0 - name: Start deployment uses: bobheadxi/deployments@v0.4.3 @@ -160,6 +159,7 @@ jobs: SENTRY_PROJECT: ${{ env.PROJECT_NAME }} with: environment: ${{ needs.metadata.outputs.stage }} + set_commits: skip - name: Finish deployment uses: bobheadxi/deployments@v0.4.3 @@ -169,12 +169,12 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} status: ${{ job.status }} deployment_id: ${{ steps.start_deployment.outputs.deployment_id }} - env_url: https://www.google.com + env_url: https://${{ needs.metadata.outputs.stage }}.csvalpha.nl update_check_run: name: Update Check Run runs-on: ubuntu-latest - needs: [branch_check, metadata, merge, continuous_integration, publish, deploy] + needs: [branch_check, metadata, merge, continuous_integration, publish_image, deploy] if: (github.ref_name == 'staging' || github.ref_name == 'master') && always() steps: - name: Get conclusion diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index dfde506c5..cff2e269e 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -57,6 +57,7 @@ jobs: uses: actions/checkout@v2 with: ref: ${{ inputs.sha }} + fetch-depth: 0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -82,18 +83,14 @@ jobs: needs.metadata.outputs.tag }} - name: Get sourcemaps from image - if: | - github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && - github.workflow == 'Continuous Delivery') + if: !(github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image') env: IMAGE_NAME: ${{ fromJSON(steps.build_push_image.outputs.metadata)['image.name'] }} run: | docker cp $(docker create $IMAGE_NAME):/usr/share/nginx/html/assets/. sourcemaps - name: Create Sentry release - if: | - github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && - github.workflow == 'Continuous Delivery') + if: !(github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image') uses: getsentry/action-release@v1 env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} diff --git a/docker-compose.yml b/docker-compose.yml index ddd25b0c7..60a946c24 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: web: - image: docker.csvalpha.nl/amber-ui:latest + image: ghcr.io/csvalpha/amber-ui:latest labels: - traefik.enable=true - traefik.frontend.rule=Host:csvalpha.nl From 08cc28e5e9e4d5809c62b488db518bf64b05044b Mon Sep 17 00:00:00 2001 From: guidojw Date: Wed, 24 Nov 2021 20:41:44 +0100 Subject: [PATCH 09/18] fix(CD): use correct environment URL --- .github/workflows/continuous-delivery.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 56d9c99a1..5b061ce20 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -125,6 +125,15 @@ jobs: github.event.inputs.merge == 'y' && fromJSON(needs.metadata.outputs.has_diff) && success()) || ((github.event.inputs.merge != 'y' || !fromJSON(needs.metadata.outputs.has_diff)) && !cancelled())) steps: + - name: Get environment URL + id: get_url + run: | + if [ $GITHUB_REF_NAME = 'master' ]; then + echo '::set-output name=environment_url::https://csvalpha.nl' + else + echo '::set-output name=environment_url::https://staging.csvalpha.nl' + fi + - name: Checkout code uses: actions/checkout@v2 with: @@ -169,7 +178,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} status: ${{ job.status }} deployment_id: ${{ steps.start_deployment.outputs.deployment_id }} - env_url: https://${{ needs.metadata.outputs.stage }}.csvalpha.nl + env_url: ${{ steps.get_url.outputs.environment_url }} update_check_run: name: Update Check Run From 46d38c4a30e8f2fe1e2e092ef18f70287f3e69d8 Mon Sep 17 00:00:00 2001 From: guidojw Date: Wed, 24 Nov 2021 23:48:43 +0100 Subject: [PATCH 10/18] chore: fix styling --- .github/workflows/continuous-integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index eb514b111..74a901d16 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -42,8 +42,8 @@ jobs: - name: Add problem matchers run: | - echo "::add-matcher::.github/problem-matchers/eslint-stylish.json" - echo "::add-matcher::.github/problem-matchers/stylelint.json" + echo '::add-matcher::.github/problem-matchers/eslint-stylish.json' + echo '::add-matcher::.github/problem-matchers/stylelint.json' - name: Set up Node.js uses: actions/setup-node@v2 From 3cf71f1f1da4967bb6dc2088bec1d4cba898c693 Mon Sep 17 00:00:00 2001 From: guidojw Date: Thu, 25 Nov 2021 12:22:28 +0100 Subject: [PATCH 11/18] chore: remove double space --- .github/workflows/publish-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index cff2e269e..f2b671bc5 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -126,4 +126,4 @@ jobs: private_key: ${{ secrets.APP_PRIVATE_KEY }} name: Publish Image conclusion: ${{ steps.get_conclusion.outputs.conclusion }} - details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} From 50dd0bb778363568b0795bc31c2faff49ce33969 Mon Sep 17 00:00:00 2001 From: guidojw Date: Thu, 25 Nov 2021 17:26:31 +0100 Subject: [PATCH 12/18] fix: Sentry release conditionals --- .github/workflows/continuous-delivery.yml | 3 +-- .github/workflows/publish-image.yml | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 5b061ce20..80c546d2c 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -191,13 +191,12 @@ jobs: env: RESULTS: ${{ join(needs.*.result, ' ') }} run: | + echo '::set-output name=conclusion::success' for RESULT in $RESULTS; do if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then echo '::set-output name=conclusion::'$RESULT - exit fi done - echo '::set-output name=conclusion::success' - name: Update Continuous Delivery check run uses: guidojw/actions/update-check-run@v1 diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index f2b671bc5..c6732488c 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -83,14 +83,14 @@ jobs: needs.metadata.outputs.tag }} - name: Get sourcemaps from image - if: !(github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image') + if: ${{ !(github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image') }} env: IMAGE_NAME: ${{ fromJSON(steps.build_push_image.outputs.metadata)['image.name'] }} run: | docker cp $(docker create $IMAGE_NAME):/usr/share/nginx/html/assets/. sourcemaps - name: Create Sentry release - if: !(github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image') + if: ${{ !(github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image') }} uses: getsentry/action-release@v1 env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} @@ -111,13 +111,12 @@ jobs: env: RESULTS: ${{ join(needs.*.result, ' ') }} run: | + echo '::set-output name=conclusion::success' for RESULT in $RESULTS; do if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then echo '::set-output name=conclusion::'$RESULT - exit fi done - echo '::set-output name=conclusion::success' - name: Update Publish Image check run uses: guidojw/actions/update-check-run@v1 From c7d3e85a863ab2e88f736a2d6485d78a5b0e6172 Mon Sep 17 00:00:00 2001 From: guidojw Date: Thu, 25 Nov 2021 17:36:12 +0100 Subject: [PATCH 13/18] fix: break out of loop when failing conclusion is found --- .github/workflows/continuous-delivery.yml | 1 + .github/workflows/publish-image.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 80c546d2c..4f14dc7d1 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -195,6 +195,7 @@ jobs: for RESULT in $RESULTS; do if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then echo '::set-output name=conclusion::'$RESULT + break fi done diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index c6732488c..fcad94c9c 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -115,6 +115,7 @@ jobs: for RESULT in $RESULTS; do if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then echo '::set-output name=conclusion::'$RESULT + break fi done From a96fb4e06940cf8698d7fcabdcc8122358c2b784 Mon Sep 17 00:00:00 2001 From: guidojw Date: Sun, 28 Nov 2021 16:48:09 +0100 Subject: [PATCH 14/18] feat: use max cache mode to export both stages --- .github/workflows/publish-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index fcad94c9c..32edbd210 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -77,7 +77,7 @@ jobs: context: . build-args: ${{ needs.metadata.outputs.build_args }} cache-from: type=gha,scope=main - cache-to: type=gha,scope=main + cache-to: type=gha,mode=max,scope=main tags: | ${{ env.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.PROJECT_NAME }}:${{ needs.metadata.outputs.tag }} From 905d6165044a8ecfbc994b99682d63b124e8db1f Mon Sep 17 00:00:00 2001 From: guidojw Date: Sun, 28 Nov 2021 18:15:30 +0100 Subject: [PATCH 15/18] fix(CI): remove concurrency setting --- .github/workflows/continuous-integration.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 74a901d16..529f8b6b7 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -10,10 +10,6 @@ on: required: false type: string -concurrency: - group: ci-${{ github.ref_name }} - cancel-in-progress: true - jobs: build: name: Build From 9a50da1bd31a788e2162acb69274778c3b5cb283 Mon Sep 17 00:00:00 2001 From: guidojw Date: Mon, 29 Nov 2021 15:38:14 +0100 Subject: [PATCH 16/18] feat: let babel output sourcemaps too --- .github/workflows/publish-image.yml | 1 + ember-cli-build.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 32edbd210..e9215695b 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -99,6 +99,7 @@ jobs: environment: ${{ needs.metadata.outputs.stage }} finalize: false sourcemaps: sourcemaps + url_prefix: ~/assets/ update_check_run: name: Update Check Run diff --git a/ember-cli-build.js b/ember-cli-build.js index b14b9688a..4a48b1bf6 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -28,7 +28,8 @@ module.exports = function(defaults) { }, babel: { - plugins: [require.resolve('@babel/plugin-proposal-optional-chaining')] + plugins: [require.resolve('@babel/plugin-proposal-optional-chaining')], + sourceMaps: 'inline' } }); From 8d8c29f4d8e6bda37e93e15ec01f0e6ce0c1657d Mon Sep 17 00:00:00 2001 From: guidojw Date: Tue, 30 Nov 2021 18:13:11 +0100 Subject: [PATCH 17/18] fix: reusable workflow secrets --- .github/workflows/continuous-delivery.yml | 2 ++ .github/workflows/publish-image.yml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 4f14dc7d1..6aa425f8f 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -115,6 +115,8 @@ jobs: uses: csvalpha/amber-ui/.github/workflows/publish-image.yml@staging with: sha: ${{ needs.merge.outputs.sha }} + secrets: + sentry_auth_token: ${{ secrets.SENTRY_AUTH_TOKEN }} deploy: name: Deploy diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index e9215695b..f8391da17 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -8,6 +8,9 @@ on: sha: required: false type: string + secrets: + sentry_auth_token: + required: true workflow_dispatch: env: From 0c3c142956b26b606fd6015fa8413453e2457b8d Mon Sep 17 00:00:00 2001 From: guidojw <35309288+guidojw@users.noreply.github.com> Date: Thu, 9 Dec 2021 00:10:39 +0100 Subject: [PATCH 18/18] refactor: use label for setting maintainer in Dockerfile.test --- Dockerfile.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.test b/Dockerfile.test index ac0cec195..5e645723b 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -1,5 +1,5 @@ FROM madnificent/ember:3.17.0 as ember -MAINTAINER C.S.V. Alpha +LABEL maintainer="C.S.V. Alpha " ENV NODE_ENV=test ENV CI=true