Repository navigation
ci: Move qemu image builds to nix build just like build-ami #2581
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| name: Release QEMU image | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - develop | ||
| - release/* | ||
| paths: | ||
| - ansible/postgres_release.yml | ||
| workflow_dispatch: | ||
| inputs: | ||
| arch: | ||
| description: Guest architecture (amd64 is experimental and publishes only to staging) | ||
| type: choice | ||
| default: arm64 | ||
| options: | ||
| - arm64 | ||
| - amd64 | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: $/.github/workflows/qemu-image-build.yml | ||
| with: | ||
| arch: ${{ inputs.arch || 'arm64' }} | ||
| publish: true | ||
|
|
||
| publish: | ||
| needs: build | ||
| runs-on: ${{ inputs.arch == 'amd64' && 'blacksmith-16vcpu-ubuntu-2404' || 'arm-native-runner' }} | ||
| timeout-minutes: 60 | ||
| env: | ||
| POSTGRES_MAJOR_VERSION: "17" | ||
| TARGET_ARCH: ${{ inputs.arch || 'arm64' }} | ||
| IMAGE_TAG: ${{ needs.build.outputs.version }} | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v7.0.1 | ||
|
|
||
| - name: Install Nix | ||
| uses: $/.github/actions/install-nix | ||
|
|
||
| - name: Download disk image | ||
| uses: actions/download-artifact@v8.0.2 | ||
| with: | ||
| name: ${{ needs.build.outputs.artifact }} | ||
| path: ${{ runner.temp }}/disk-image | ||
|
|
||
| - name: Build image | ||
| run: | | ||
| mkdir -p image-context/output-cloudimg | ||
| nix run nixpkgs#zstd -- -d -o image-context/output-cloudimg/packer-cloudimg "$RUNNER_TEMP/disk-image/packer-cloudimg.zst" | ||
| docker build --platform "linux/$TARGET_ARCH" -f Dockerfile-kubernetes -t "postgres:$IMAGE_TAG" image-context | ||
|
|
||
| - name: configure aws credentials - staging | ||
| uses: aws-actions/configure-aws-credentials@v6.3.0 | ||
| with: | ||
| role-to-assume: ${{ secrets.CONTROL_PLANE_DEV_ROLE }} | ||
| aws-region: "us-east-1" | ||
|
|
||
| - name: Login to Amazon ECR Staging | ||
| id: login-ecr-private-dev | ||
| uses: aws-actions/amazon-ecr-login@v2.1.7 | ||
|
|
||
| - name: Push docker image to Amazon ECR | ||
| env: | ||
| REGISTRY: 812073016711.dkr.ecr.us-east-1.amazonaws.com | ||
| REPOSITORY: postgres-vm-image | ||
| run: | | ||
| docker tag "postgres:$IMAGE_TAG" "$REGISTRY/$REPOSITORY:$IMAGE_TAG" | ||
| docker push "$REGISTRY/$REPOSITORY:$IMAGE_TAG" | ||
|
|
||
| # TODO (darora): temporarily also push to prod account from here - add a guard to only publish proper tagged releases to prod? | ||
| - name: configure aws credentials - prod | ||
| if: env.TARGET_ARCH == 'arm64' | ||
| uses: aws-actions/configure-aws-credentials@v6.3.0 | ||
| with: | ||
| role-to-assume: ${{ secrets.CONTROL_PLANE_PROD_ROLE }} | ||
| aws-region: "us-east-1" | ||
|
|
||
| - name: Login to Amazon ECR Prod | ||
| if: env.TARGET_ARCH == 'arm64' | ||
| id: login-ecr-private-prod | ||
| uses: aws-actions/amazon-ecr-login@v2.1.7 | ||
|
|
||
| - name: Push docker image to Amazon ECR Prod | ||
| if: env.TARGET_ARCH == 'arm64' | ||
| env: | ||
| REGISTRY: 156470330064.dkr.ecr.us-east-1.amazonaws.com | ||
| REPOSITORY: postgres-vm-image | ||
| run: | | ||
| docker tag "postgres:$IMAGE_TAG" "$REGISTRY/$REPOSITORY:$IMAGE_TAG" | ||
| docker push "$REGISTRY/$REPOSITORY:$IMAGE_TAG" | ||
|
|
||
| notify: | ||
| needs: [build, publish] | ||
| if: failure() | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
| steps: | ||
| - name: Slack Notification on Failure | ||
| uses: slackapi/slack-github-action@v4.0.0 | ||
| with: | ||
| webhook: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }} | ||
| webhook-type: incoming-webhook | ||
| payload: | | ||
| username: gha-failure | ||
| icon_emoji: ':old_man_yells_at_github_actions:' | ||
| channel: C0C16MJ8WHX | ||
| text: | | ||
| *Building Postgres QEMU artifact failed* | ||
| *Actions URL:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ github.workflow }}> | ||
| *Event:* ${{ github.event_name }} | ||
| *Ref:* ${{ github.ref }} | ||
| *Commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
publishbuilds this image again. Skip it here when publishing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not going to do this because then we don't be building the Dockerfile for PRs and such, only during builds after merge. This means we could introduce some breakage in the setup and not know about it. As it is now we end up building the docker image twice which imo is pretty cheap/not a big deal. This will go away soon when we drop the ability to run this manually and publishing can happen from -build.