1 name: Build CI Container
11 - .github/workflows/build-ci-container.yml
12 - '.github/workflows/containers/github-action-ci/**'
17 - .github/workflows/build-ci-container.yml
18 - '.github/workflows/containers/github-action-ci/**'
22 if: github.repository_owner == 'llvm'
23 runs-on: depot-ubuntu-22.04-16
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 }}
30 uses: actions/checkout@v4
32 sparse-checkout: .github/workflows/containers/github-action-ci/
33 - name: Write Variables
37 container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04"
38 echo "container-name=$container_name" >> $GITHUB_OUTPUT
39 echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
40 echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
41 - name: Build container
42 working-directory: ./.github/workflows/containers/github-action-ci/
44 podman build -t ${{ steps.vars.outputs.container-name-tag }} .
46 # Save the container so we have it in case the push fails. This also
47 # allows us to separate the push step into a different job so we can
48 # maintain minimal permissions while building the container.
49 - name: Save container image
51 podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
53 - name: Upload container image
54 uses: actions/upload-artifact@v4
57 path: ${{ steps.vars.outputs.container-filename }}
60 - name: Test Container
62 for image in ${{ steps.vars.outputs.container-name-tag }}; do
63 # Use --pull=never to ensure we are testing the just built image.
64 podman run --pull=never --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
68 if: github.event_name == 'push'
75 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77 - name: Download container
78 uses: actions/download-artifact@v4
82 - name: Push Container
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
86 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