Repository navigation
ci: Derive EC2 artifacts from ECS build #16821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b6f4045
3eedf02
c9136ea
9c4aa43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,114 @@ | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| container-image: | ||
| description: 'Image used by DCR service' | ||
| production-image-digest: | ||
| description: 'Digest of DCR image in AWS ECR' | ||
| required: true | ||
| type: string | ||
| secrets: | ||
| GU_RIFF_RAFF_ROLE_ARN: | ||
| required: true | ||
| GU_ARTIFACTS_ROLE_ARN: | ||
| required: true | ||
|
|
||
| permissions: | ||
| # Allow GitHub to request an OIDC JWT ID token, and to comment on pull requests as required by guardian/actions-riff-raff | ||
| id-token: write | ||
| pull-requests: write | ||
| contents: read | ||
| jobs: | ||
| riffraff: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v7 | ||
|
akash1810 marked this conversation as resolved.
|
||
|
|
||
| - name: Set up Node environment | ||
| uses: ./.github/actions/setup-node-env | ||
|
|
||
| # TODO abstract this into a reusable GitHub Action e.g. https://github.com/guardian/actions-publish-image | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Along with #16811 and guardian/commercial#2745 we've done this three times, so it's time to refactor! This'll be done in a separate PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| - name: AWS ECR configure credentials | ||
| uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 | ||
| with: | ||
| role-to-assume: ${{ secrets.GU_ARTIFACTS_ROLE_ARN }} | ||
| aws-region: eu-west-1 | ||
| mask-aws-account-id: 'true' | ||
|
|
||
| # TODO abstract this into a reusable GitHub Action e.g. https://github.com/guardian/actions-publish-image | ||
| - name: AWS ECR login | ||
| id: ecr-login | ||
| uses: aws-actions/amazon-ecr-login@03f1aad4c6c7ffd436567f42f9384779290529bd # v2.1.7 | ||
| with: | ||
| mask-password: 'true' | ||
|
|
||
| # Clear AWS credentials (stored in environment variables) to avoid leaking them to any subsequent steps | ||
| # See https://github.com/aws-actions/configure-aws-credentials/issues/1308 | ||
| # TODO abstract this into a reusable GitHub Action e.g. https://github.com/guardian/actions-publish-image | ||
| - name: AWS ECR clear credentials | ||
| if: always() | ||
| shell: bash | ||
| run: | | ||
| echo "AWS_ACCESS_KEY_ID=''" >>"$GITHUB_ENV" | ||
| echo "AWS_SECRET_ACCESS_KEY=''" >>"$GITHUB_ENV" | ||
| echo "AWS_SESSION_TOKEN=''" >>"$GITHUB_ENV" | ||
| echo "AWS_DEFAULT_REGION=''" >>"$GITHUB_ENV" | ||
| echo "AWS_REGION=''" >>"$GITHUB_ENV" | ||
|
|
||
| # TODO abstract this into a reusable GitHub Action e.g. https://github.com/guardian/actions-publish-image | ||
| - name: AWS ECR pull image | ||
| id: ecr-pull | ||
| env: | ||
| REGISTRY: ${{ steps.ecr-login.outputs.registry }} | ||
| run: | | ||
| IMAGE="$REGISTRY/guardian/dotcom-rendering@${{ inputs.production-image-digest }}" | ||
| docker pull $IMAGE | ||
| echo "IMAGE=$IMAGE" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # Annoyingly we can't _easily_ access an Images filesystem without creating a container from the image. | ||
| # we don't necessarily have to start the container, but we do need to create it. | ||
| - name: Create DCR Container | ||
| id: create-container | ||
| run: echo "CONTAINER_ID=$(docker create ${{ inputs.container-image }})" >> "$GITHUB_OUTPUT" | ||
| - name: Move container files into GHA Workspace | ||
| run: docker cp ${{ steps.create-container.outputs.CONTAINER_ID }}:/opt/app/dotcom-rendering/dotcom-rendering/. ${{ github.workspace }} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the main change. Previously we sourced files from within the GitHub hosted Docker image. Now we source files from the ECR hosted Docker image. |
||
| - name: Copy container files into GHA Workspace | ||
| working-directory: dotcom-rendering | ||
| run: | | ||
| CONTAINER_ID=$(docker create ${{ steps.ecr-pull.outputs.IMAGE }}) | ||
| docker cp $CONTAINER_ID:/app/. dist | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy files into Footnotes
|
||
|
|
||
| - name: CDK synth | ||
| env: | ||
| IMAGE_DIGEST: ${{ inputs.production-image-digest }} | ||
| working-directory: dotcom-rendering | ||
| run: make cdk-synth | ||
|
Comment on lines
+76
to
+80
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Performing CDK synth as a discrete step makes it more explicit where the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The synthed files were previously in the GitHub hosted Docker image. They do not form part of the ECR hosted image so we synth here. Consequently, this workflow also now clones includes |
||
|
|
||
| - name: Construct EC2 artifacts | ||
| working-directory: dotcom-rendering | ||
| run: make riffraff-bundle | ||
|
|
||
| # We want to avoid uploading the uncompressed files to our riffraff bucket | ||
| # so we create our tarball outside the folder, then delete the contents of | ||
| # the folder, and finally move the tarball into the folder. | ||
| - name: Compress article-rendering app server files | ||
| working-directory: dotcom-rendering/target | ||
| run: | | ||
| tar -zcf article-rendering.tar.gz article-rendering | ||
| rm -r article-rendering/* | ||
| mv article-rendering.tar.gz article-rendering/ | ||
|
|
||
| - name: Compress facia-rendering app server files | ||
| working-directory: dotcom-rendering/target | ||
| run: | | ||
| tar -zcf facia-rendering.tar.gz facia-rendering | ||
| rm -r facia-rendering/* | ||
| mv facia-rendering.tar.gz facia-rendering/ | ||
|
|
||
| - name: Compress tag-page-rendering app server files | ||
| working-directory: dotcom-rendering/target | ||
| run: | | ||
| tar -zcf tag-page-rendering.tar.gz tag-page-rendering | ||
| rm -r tag-page-rendering/* | ||
| mv tag-page-rendering.tar.gz tag-page-rendering/ | ||
|
|
||
| - name: Compress interactive-rendering app server files | ||
| working-directory: dotcom-rendering/target | ||
| run: | | ||
| tar -zcf interactive-rendering.tar.gz interactive-rendering | ||
| rm -r interactive-rendering/* | ||
|
|
@@ -60,23 +121,23 @@ jobs: | |
| githubToken: ${{ secrets.GITHUB_TOKEN }} | ||
| roleArn: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }} | ||
| projectName: dotcom:rendering-all | ||
| configPath: riff-raff.yaml | ||
| configPath: dotcom-rendering/target/riff-raff.yaml | ||
| contentDirectories: | | ||
| article-rendering-cfn: | ||
| - article-rendering-cfn | ||
| - dotcom-rendering/target/article-rendering-cfn | ||
| article-rendering: | ||
| - article-rendering | ||
| - dotcom-rendering/target/article-rendering | ||
| facia-rendering-cfn: | ||
| - facia-rendering-cfn | ||
| - dotcom-rendering/target/facia-rendering-cfn | ||
| facia-rendering: | ||
| - facia-rendering | ||
| - dotcom-rendering/target/facia-rendering | ||
| tag-page-rendering-cfn: | ||
| - tag-page-rendering-cfn | ||
| - dotcom-rendering/target/tag-page-rendering-cfn | ||
| tag-page-rendering: | ||
| - tag-page-rendering | ||
| - dotcom-rendering/target/tag-page-rendering | ||
| interactive-rendering-cfn: | ||
| - interactive-rendering-cfn | ||
| - dotcom-rendering/target/interactive-rendering-cfn | ||
| interactive-rendering: | ||
| - interactive-rendering | ||
| - dotcom-rendering/target/interactive-rendering | ||
| frontend-static: | ||
| - frontend-static | ||
| - dotcom-rendering/target/frontend-static | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ cdk-synth: | |
| cdk-diff: | ||
| @pnpm cdk diff --path-metadata false --version-reporting false --profile frontend | ||
|
|
||
| riffraff-bundle: clean-dist build cdk-synth | ||
| riffraff-bundle: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
| $(call log, "creating riffraff bundle") | ||
| @node ./scripts/deploy/build-riffraff-bundle.mjs | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,2 +1,2 @@ | ||||||||
| // this should get overwritten in CI (see .github/workflows/container.yml) | ||||||||
| // this should get overwritten in CI (see .github/workflows/container-production.yml) | ||||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dotcom-rendering/.github/workflows/container-production.yml Lines 36 to 38 in a598f34
|
||||||||
| export const GIT_COMMIT_HASH = 'LOCAL'; | ||||||||
Uh oh!
There was an error while loading. Please reload this page.