Build amd64 and arm64 #3
This file contains 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
name: Build amd64 and arm64 | |
on: | |
workflow_dispatch: | |
schedule: | |
# run Mon, Wed, Fri at 03:00 UTC | |
- cron: '00 03 * * 1,3,5' | |
env: | |
LATEST_MAJOR: 9 | |
IMAGE_NAME: almalinux-bootc | |
VERSIONS_LIST: '"9"' # '"9", "10"' | |
jobs: | |
set-versions-matrix: | |
name: Set versions matrix | |
runs-on: ubuntu-24.04 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- id: set-matrix | |
run: echo "matrix=[${{ env.VERSIONS_LIST }}]" >> $GITHUB_OUTPUT | |
build-amd64: | |
name: amd64 '${{ matrix.VERSION_MAJOR}}' image | |
runs-on: ubuntu-24.04 | |
needs: [set-versions-matrix] | |
strategy: | |
fail-fast: false | |
matrix: | |
VERSION_MAJOR: ${{ fromJSON(needs.set-versions-matrix.outputs.matrix) }} | |
env: | |
PLATFORM: linux/amd64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: ./.github/actions/shared-steps | |
name: Build and Push | |
with: | |
VERSION_MAJOR: ${{ matrix.VERSION_MAJOR }} | |
IMAGE_REGISTRY: ${{ secrets.IMAGE_REGISTRY }} | |
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | |
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | |
start-arm64-runner: | |
timeout-minutes: 10 # normally it only takes 1-2 minutes | |
name: arm64 self-hosted runner for '${{ matrix.VERSION_MAJOR}}' | |
runs-on: ubuntu-24.04 | |
needs: [set-versions-matrix] | |
strategy: | |
fail-fast: false | |
matrix: | |
VERSION_MAJOR: ${{ fromJSON(needs.set-versions-matrix.outputs.matrix) }} | |
steps: | |
- name: Setup and start the runner | |
id: start-ec2-runner | |
uses: NextChapterSoftware/[email protected] | |
with: | |
github_token: ${{ secrets.GIT_HUB_TOKEN }} | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws_region: ${{ secrets.AWS_REGION }} | |
ec2_ami_id: ${{ matrix.VERSION_MAJOR == '9' && secrets.EC2_AMI_ID_AL9 }} | |
ec2_subnet_id: ${{ secrets.EC2_SUBNET_ID}} | |
ec2_security_group_id: ${{ secrets.EC2_SECURITY_GROUP_ID }} | |
ec2_instance_type: t4g.medium # 2 vCPU and 4 GiM Memory | |
ec2_root_disk_size_gb: "16" # override default size which is too small for images | |
ec2_root_disk_ebs_class: "gp3" # use faster and cheeper storage instead of default 'gp2' | |
ec2_instance_ttl: 60 # Optional (default is 60 minutes) | |
ec2_spot_instance_strategy: None # Other options are: SpotOnly, BestEffort, MaxPerformance | |
ec2_instance_tags: > # Required for IAM role resource permission scoping | |
[ | |
{"Key": "Project", "Value": "GitHub Actions Self-hosted Runners"} | |
] | |
build-arm64: | |
name: arm64 '${{ matrix.VERSION_MAJOR}}' image | |
runs-on: ${{ github.run_id }} | |
needs: [set-versions-matrix, start-arm64-runner] | |
strategy: | |
fail-fast: false | |
matrix: | |
VERSION_MAJOR: ${{ fromJSON(needs.set-versions-matrix.outputs.matrix) }} | |
env: | |
PLATFORM: linux/arm64 | |
steps: | |
- name: Install dependencies | |
run: | | |
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo | |
sudo yum -y -q install docker-ce docker-ce-cli containerd.io podman git | |
sudo systemctl start docker | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: ./.github/actions/shared-steps | |
name: Build and Push | |
with: | |
VERSION_MAJOR: ${{ matrix.VERSION_MAJOR }} | |
IMAGE_REGISTRY: ${{ secrets.IMAGE_REGISTRY }} | |
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | |
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} |