2020jobs :
2121 build-ci-container :
2222 if : github.repository_owner == 'llvm'
23- runs-on : depot-ubuntu-22.04-16
24- outputs :
25- container-name : ${{ steps.vars.outputs.container-name }}
26- container-name-tag : ${{ steps.vars.outputs.container-name-tag }}
27- container-filename : ${{ steps.vars.outputs.container-filename }}
23+ runs-on : ${{ matrix.runs-on }}
24+ strategy :
25+ matrix :
26+ include :
27+ # The arch names should match the names used on dockerhub.
28+ # See https://github.com/docker-library/official-images#architectures-other-than-amd64
29+ - arch : amd64
30+ runs-on : depot-ubuntu-22.04-16
31+ - arch : arm64v8
32+ runs-on : depot-ubuntu-22.04-arm-16
2833 steps :
2934 - name : Checkout LLVM
30- uses : actions/checkout@v4
35+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3136 with :
3237 sparse-checkout : .github/workflows/containers/github-action-ci/
38+ # podman is not installed by default on the ARM64 images.
39+ - name : Install Podman
40+ if : runner.arch == 'ARM64'
41+ run : |
42+ sudo apt-get install podman
3343 - name : Write Variables
3444 id : vars
3545 run : |
36- tag=`date +%s`
37- container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04"
46+ tag=$(git rev-parse --short=12 HEAD)
47+ container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/${{ matrix.arch }}/ ci-ubuntu-22.04"
3848 echo "container-name=$container_name" >> $GITHUB_OUTPUT
49+ echo "container-name-agent=$container_name-agent" >> $GITHUB_OUTPUT
3950 echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
51+ echo "container-name-agent-tag=$container_name-agent:$tag" >> $GITHUB_OUTPUT
4052 echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
53+ echo "container-agent-filename=$(echo $container_name-agent:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
4154 - name : Build container
4255 working-directory : ./.github/workflows/containers/github-action-ci/
4356 run : |
44- podman build -t ${{ steps.vars.outputs.container-name-tag }} .
57+ podman build --target ci-container -t ${{ steps.vars.outputs.container-name-tag }} .
58+ podman build --target ci-container-agent -t ${{ steps.vars.outputs.container-name-agent-tag }} .
4559
4660 # Save the container so we have it in case the push fails. This also
4761 # allows us to separate the push step into a different job so we can
4862 # maintain minimal permissions while building the container.
4963 - name : Save container image
5064 run : |
51- podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
65+ podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
66+ podman save ${{ steps.vars.outputs.container-name-agent-tag }} > ${{ steps.vars.outputs.container-agent-filename }}
5267
5368 - name : Upload container image
54- uses : actions/upload-artifact@v4
69+ uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
5570 with :
56- name : container
57- path : ${{ steps.vars.outputs.container-filename }}
71+ name : container-${{ matrix.arch }}
72+ path : " *.tar "
5873 retention-days : 14
5974
6075 - name : Test Container
@@ -75,14 +90,30 @@ jobs:
7590 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7691 steps :
7792 - name : Download container
78- uses : actions/download-artifact@v4
79- with :
80- name : container
93+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
8194
8295 - name : Push Container
8396 run : |
84- podman load -i ${{ needs.build-ci-container.outputs.container-filename }}
85- podman tag ${{ needs.build-ci-container.outputs.container-name-tag }} ${{ needs.build-ci-container.outputs.container-name }}:latest
97+ function push_container {
98+ image_name=$1
99+ latest_name=$(echo $image_name | sed 's/:[a-f0-9]\+$/:latest/g')
100+ podman tag $image_name $latest_name
101+ echo "Pushing $image_name ..."
102+ podman push $image_name
103+ echo "Pushing $latest_name ..."
104+ podman push $latest_name
105+ }
106+
86107 podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
87- podman push ${{ needs.build-ci-container.outputs.container-name-tag }}
88- podman push ${{ needs.build-ci-container.outputs.container-name }}:latest
108+ for f in $(find . -iname *.tar); do
109+ image_name=$(podman load -q -i $f | sed 's/Loaded image: //g')
110+ push_container $image_name
111+
112+ if echo $image_name | grep '/amd64/'; then
113+ # For amd64, create an alias with the arch component removed.
114+ # This matches the convention used on dockerhub.
115+ default_image_name=$(echo $(dirname $(dirname $image_name))/$(basename $image_name))
116+ podman tag $image_name $default_image_name
117+ push_container $default_image_name
118+ fi
119+ done
0 commit comments