Skip to content

Commit 57724b1

Browse files
authored
feat: need this workflow present to test (#1941)
1 parent d95ee44 commit 57724b1

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build Base Image Nightly
2+
3+
on:
4+
#schedule:
5+
# - cron: '0 2 * * *' # 2 AM UTC daily
6+
workflow_dispatch:
7+
inputs:
8+
branch:
9+
description: 'Branch to build from'
10+
required: false
11+
default: 'develop'
12+
type: string
13+
14+
permissions:
15+
contents: read
16+
id-token: write
17+
18+
jobs:
19+
build-base-image:
20+
runs-on: blacksmith-4vcpu-ubuntu-2404-arm
21+
timeout-minutes: 150
22+
23+
steps:
24+
- name: Checkout Repo
25+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
26+
with:
27+
ref: ${{ github.event.inputs.branch || 'develop' }}
28+
29+
- name: Configure AWS credentials
30+
uses: aws-actions/configure-aws-credentials@v4
31+
with:
32+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
33+
aws-region: "us-east-1"
34+
output-credentials: true
35+
role-duration-seconds: 7200
36+
37+
- name: Install nix
38+
uses: cachix/install-nix-action@v27
39+
with:
40+
install_url: https://releases.nixos.org/nix/nix-2.29.1/install
41+
extra_nix_config: |
42+
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
43+
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
44+
45+
- name: Set execution ID and timestamp
46+
run: |
47+
echo "EXECUTION_ID=${{ github.run_id }}-base-nightly" >> $GITHUB_ENV
48+
echo "BUILD_TIMESTAMP=$(date -u +%Y%m%d-%H%M%S)" >> $GITHUB_ENV
49+
50+
- name: Build base stage 1 AMI
51+
env:
52+
AWS_MAX_ATTEMPTS: 10
53+
AWS_RETRY_MODE: adaptive
54+
run: |
55+
GIT_SHA=${{ github.sha }}
56+
nix run github:supabase/postgres/${GIT_SHA}#packer -- init amazon-arm64-nix.pkr.hcl
57+
nix run github:supabase/postgres/${GIT_SHA}#packer -- build \
58+
-var "git-head-version=${GIT_SHA}" \
59+
-var "packer-execution-id=${EXECUTION_ID}" \
60+
-var-file="development-arm.vars.pkr.hcl" \
61+
-var "base-image-nightly=true" \
62+
-var "build-timestamp=${BUILD_TIMESTAMP}" \
63+
-var "region=us-east-1" \
64+
-var 'ami_regions=["us-east-1","ap-southeast-1"]' \
65+
amazon-arm64-nix.pkr.hcl
66+
67+
- name: Slack Notification on Failure
68+
if: ${{ failure() }}
69+
uses: rtCamp/action-slack-notify@v2
70+
env:
71+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
72+
SLACK_USERNAME: 'gha-failures-notifier'
73+
SLACK_COLOR: 'danger'
74+
SLACK_MESSAGE: 'Building base image nightly failed'
75+
SLACK_FOOTER: ''
76+
77+
- name: Cleanup resources after build
78+
if: ${{ always() }}
79+
run: |
80+
aws ec2 --region us-east-1 describe-instances --filters "Name=tag:packerExecutionId,Values=${EXECUTION_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --region us-east-1 --instance-ids
81+
82+
- name: Cleanup resources on build cancellation
83+
if: ${{ cancelled() }}
84+
run: |
85+
aws ec2 --region us-east-1 describe-instances --filters "Name=tag:packerExecutionId,Values=${EXECUTION_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --region us-east-1 --instance-ids

0 commit comments

Comments
 (0)