Skip to content

Commit 5ef3aa8

Browse files
committed
Publish ARM Ansible Docker images
1 parent b5ab05d commit 5ef3aa8

File tree

5 files changed

+146
-141
lines changed

5 files changed

+146
-141
lines changed

.github/workflows/build.yml

+116-31
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,132 @@ name: Build
22

33
on:
44
push:
5-
branches-ignore:
6-
- main
7-
- future
5+
branches-ignore: [main, future]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
811
jobs:
9-
base:
10-
name: Build and deploy the base Alpine image
12+
build:
1113
runs-on: ubuntu-latest
14+
name: 👷 Build ${{ matrix.folder }} image
15+
strategy:
16+
fail-fast: false
17+
max-parallel: 2 # ECR has pretty aggressive rate limiting 😪
18+
matrix:
19+
folder: [base, aws]
20+
arch: [amd64, arm64]
21+
env:
22+
IMAGE_NAME: ansible-test-${{ matrix.folder }}-${{ matrix.arch }}:${{ github.sha }}
1223
steps:
1324
- name: Check out repository code
14-
uses: actions/checkout@master
15-
16-
- name: Set up Docker Buildx
17-
uses: docker/setup-buildx-action@v1
25+
uses: actions/checkout@main
1826

19-
- name: Build and push the image
20-
uses: docker/build-push-action@v2
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v2
29+
if: matrix.arch == 'arm64'
2130
with:
22-
context: base
23-
push: false
24-
tags: |
25-
${{ secrets.PREPROD_PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
26-
ghcr.io/spacelift-io/runner-ansible:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
27-
28-
aws:
29-
name: Build and deploy the alpine base AWS image
30-
runs-on: ubuntu-latest
31-
steps:
32-
- name: Check out repository code
33-
uses: actions/checkout@master
34-
- name: Set env
35-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
31+
platforms: linux/arm64
3632

3733
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v1
34+
uses: docker/setup-buildx-action@v2
3935

40-
- name: Build and push the image
41-
uses: docker/build-push-action@v2
36+
- name: Build the ${{ matrix.folder }} image
37+
uses: docker/build-push-action@v3
4238
with:
39+
context: ${{ matrix.folder }}
4340
build-args: |
4441
REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
45-
context: aws
4642
push: false
47-
tags: |
48-
${{ secrets.PREPROD_PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
43+
load: true
44+
platforms: linux/${{ matrix.arch }}
45+
tags: ${{ env.IMAGE_NAME }}
46+
47+
- name: Test if ansible and Python binary works
48+
run: |
49+
# We need to rebuild the images because the previous step is a multi-arch build
50+
# and it doesn't produce outputs unfortunately.
51+
52+
# docker build --platform linux/${{ matrix.arch }} --build-arg REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }} -t $IMAGE_NAME ${{ matrix.folder }}
53+
docker run --rm ${{ env.IMAGE_NAME }} ansible --version
54+
55+
if [ "${{ matrix.folder }}" == "aws" ]; then
56+
docker run --rm ${{ env.IMAGE_NAME }} sh -c "python3 -c \"import boto3; print(boto3.__version__)\""
57+
fi
58+
59+
# base:
60+
# name: Build and deploy the base Alpine image
61+
# runs-on: ubuntu-latest
62+
# steps:
63+
# - name: Check out repository code
64+
# uses: actions/checkout@main
65+
66+
# - name: Set up QEMU
67+
# uses: docker/setup-qemu-action@v2
68+
# with:
69+
# platforms: linux/arm64
70+
71+
# - name: Set up Docker Buildx
72+
# uses: docker/setup-buildx-action@v2
73+
74+
# - name: Build and push the image
75+
# uses: docker/build-push-action@v3
76+
# with:
77+
# context: base
78+
# push: false
79+
# platforms: linux/amd64,linux/arm64
80+
# tags: |
81+
# ${{ secrets.PREPROD_PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
82+
# ghcr.io/spacelift-io/runner-ansible:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
83+
84+
# - name: Test if ansible binary works
85+
# run: |
86+
# # We need to rebuild the images because the previous step is a multi-arch build
87+
# # and it doesn't produce outputs unfortunately.
88+
89+
# # ARM64
90+
# docker build --platform linux/arm64 -t ansible-test-arm base
91+
# docker run --rm ansible-test-arm ansible --version
92+
93+
# # AMD64
94+
# docker build --platform linux/amd64 -t ansible-test-amd64 base
95+
# docker run --rm ansible-test-amd64 ansible --version
96+
97+
# aws:
98+
# name: Build and deploy the alpine base AWS image
99+
# runs-on: ubuntu-latest
100+
# steps:
101+
# - name: Check out repository code
102+
# uses: actions/checkout@main
103+
104+
# - name: Set up QEMU
105+
# uses: docker/setup-qemu-action@v2
106+
# with:
107+
# platforms: linux/arm64
108+
109+
# - name: Set up Docker Buildx
110+
# uses: docker/setup-buildx-action@v2
111+
112+
# - name: Build and push the image
113+
# uses: docker/build-push-action@v3
114+
# with:
115+
# build-args: |
116+
# REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
117+
# context: aws
118+
# push: false
119+
# tags: |
120+
# ${{ secrets.PREPROD_PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
121+
122+
# - name: Test if ansible Python & ansible binary works
123+
# run: |
124+
# # We need to rebuild the images because the previous step is a multi-arch build
125+
# # and it doesn't produce outputs unfortunately.
126+
127+
# # ARM64
128+
# docker build --platform linux/arm64 --build-arg REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }} -t ansible-test-arm aws
129+
# docker run --rm ansible-test-arm sh -c "python3 -c \"import boto3; print(boto3.__version__)\" && ansible --version"
130+
131+
# # AMD64
132+
# docker build --platform linux/amd64 --build-arg REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }} -t ansible-test-amd64 aws
133+
# docker run --rm ansible-test-amd64 sh -c "python3 -c \"import boto3; print(boto3.__version__)\" && ansible --version"

.github/workflows/deploy-preproduction.yml

-96
This file was deleted.

.github/workflows/deploy-production.yml .github/workflows/deploy.yml

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
name: Deploy Production
1+
name: Deploy
22

33
on:
44
push:
55
branches:
6+
- future
67
- main
78
schedule:
8-
- cron: "20 8 * * 1"
9+
- cron: '20 8 * * 1'
910

1011
env:
1112
AWS_REGION: "us-east-1"
@@ -20,7 +21,12 @@ jobs:
2021
runs-on: ubuntu-latest
2122
steps:
2223
- name: Check out repository code
23-
uses: actions/checkout@master
24+
uses: actions/checkout@main
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v2
28+
with:
29+
platforms: linux/arm64
2430

2531
- name: Configure AWS credentials
2632
uses: aws-actions/configure-aws-credentials@v1
@@ -46,23 +52,32 @@ jobs:
4652
password: ${{ secrets.GITHUB_TOKEN }}
4753

4854
- name: Set up Docker Buildx
49-
uses: docker/setup-buildx-action@v1
55+
uses: docker/setup-buildx-action@v2
5056

5157
- name: Build and push the image
52-
uses: docker/build-push-action@v2
58+
uses: docker/build-push-action@v3
5359
with:
5460
context: base
61+
platforms: linux/amd64,linux/arm64
5562
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }}
5663
tags: |
5764
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
65+
ghcr.io/spacelift-io/runner-ansible:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}
5866
5967
aws:
68+
if: false # skip aws build until we push base image to the repo
6069
needs: base
6170
name: Build and deploy the alpine base AWS image
6271
runs-on: ubuntu-latest
6372
steps:
6473
- name: Check out repository code
65-
uses: actions/checkout@master
74+
uses: actions/checkout@main
75+
76+
- name: Set up QEMU
77+
uses: docker/setup-qemu-action@v2
78+
with:
79+
platforms: linux/arm64
80+
6681
- name: Set env
6782
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
6883

@@ -83,14 +98,15 @@ jobs:
8398
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }}
8499

85100
- name: Set up Docker Buildx
86-
uses: docker/setup-buildx-action@v1
101+
uses: docker/setup-buildx-action@v2
87102

88103
- name: Build and push the image
89-
uses: docker/build-push-action@v2
104+
uses: docker/build-push-action@v3
90105
with:
91106
build-args: |
92107
REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
93108
context: aws
109+
platforms: linux/amd64,linux/arm64
94110
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }}
95111
tags: |
96112
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }}

.github/workflows/prod-pr.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
create-pr:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@main
1212

1313
- name: Create Pull Request
14-
uses: vsoch/pull-request-action@1.0.13
14+
uses: vsoch/pull-request-action@1.0.22
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1717
PASS_IF_EXISTS: true

.github/workflows/trivy.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Checkout code
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@main
1919

2020
- name: Build an image from Dockerfile
2121
run: |
@@ -31,7 +31,7 @@ jobs:
3131
severity: "CRITICAL,HIGH"
3232

3333
- name: Upload Trivy scan results to GitHub Security tab
34-
uses: github/codeql-action/upload-sarif@v1
34+
uses: github/codeql-action/upload-sarif@v2
3535
with:
3636
sarif_file: "trivy-results.sarif"
3737

@@ -41,7 +41,7 @@ jobs:
4141

4242
steps:
4343
- name: Checkout code
44-
uses: actions/checkout@v2
44+
uses: actions/checkout@main
4545

4646
- name: Build an image from Dockerfile
4747
run: |
@@ -57,6 +57,6 @@ jobs:
5757
severity: "CRITICAL,HIGH"
5858

5959
- name: Upload Trivy scan results to GitHub Security tab
60-
uses: github/codeql-action/upload-sarif@v1
60+
uses: github/codeql-action/upload-sarif@v2
6161
with:
6262
sarif_file: "trivy-results.sarif"

0 commit comments

Comments
 (0)