@@ -2,47 +2,132 @@ name: Build
2
2
3
3
on :
4
4
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
+
8
11
jobs :
9
- base :
10
- name : Build and deploy the base Alpine image
12
+ build :
11
13
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 }}
12
23
steps :
13
24
- 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
18
26
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'
21
30
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
36
32
37
33
- name : Set up Docker Buildx
38
- uses : docker/setup-buildx-action@v1
34
+ uses : docker/setup-buildx-action@v2
39
35
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
42
38
with :
39
+ context : ${{ matrix.folder }}
43
40
build-args : |
44
41
REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
45
- context : aws
46
42
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"
0 commit comments