|
| 1 | +--- |
| 2 | +name: Build Buildah Action Runner Image |
| 3 | + |
| 4 | +on: # yamllint disable-line rule:truthy |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - .github/workflows/image-buildah-action-runner.yml |
| 10 | + - images/buildah-action-runner/** |
| 11 | + tags: |
| 12 | + - buildah-action-runner-* |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - main |
| 16 | + paths: |
| 17 | + - .github/workflows/image-buildah-action-runner.yml |
| 18 | + - images/buildah-action-runner/** |
| 19 | + |
| 20 | +jobs: |
| 21 | + build-buildah-action-runner: |
| 22 | + name: Build Buildah Action Runner Image |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + packages: write |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout Repo |
| 30 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 31 | + - name: Login to GitHub Container Registry |
| 32 | + uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4 |
| 33 | + with: |
| 34 | + registry: ghcr.io |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + - name: Compute Version Tag |
| 38 | + env: |
| 39 | + BRANCH: ${{ github.ref_type == 'tag' && github.ref_name || github.event_name != 'pull_request' && format('{0}.{1}.{2}', github.run_id, github.run_number, github.run_attempt) || format('pr-{0}.{1}.{2}.{3}', github.event.number, github.run_id, github.run_number, github.run_attempt) }} |
| 40 | + id: version_tag |
| 41 | + run: echo "tag=$BRANCH" | sed -e 's/buildah-action-runner-//' >> "$GITHUB_OUTPUT" |
| 42 | + - name: Select Image Export Mode |
| 43 | + id: image_export |
| 44 | + env: |
| 45 | + HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} |
| 46 | + run: | |
| 47 | + set -euo pipefail |
| 48 | +
|
| 49 | + if [[ "${GITHUB_EVENT_NAME}" == "pull_request" && "${HEAD_REPOSITORY}" != "${GITHUB_REPOSITORY}" ]]; then |
| 50 | + echo "load=true" >> "$GITHUB_OUTPUT" |
| 51 | + echo "push=false" >> "$GITHUB_OUTPUT" |
| 52 | + else |
| 53 | + echo "load=false" >> "$GITHUB_OUTPUT" |
| 54 | + echo "push=true" >> "$GITHUB_OUTPUT" |
| 55 | + fi |
| 56 | + - name: Generate Metadata |
| 57 | + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 |
| 58 | + id: metadata |
| 59 | + with: |
| 60 | + images: ghcr.io/${{ github.repository_owner }}/buildah-action-runner |
| 61 | + - name: Build Image |
| 62 | + id: build |
| 63 | + uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 |
| 64 | + with: |
| 65 | + context: images/buildah-action-runner |
| 66 | + file: images/buildah-action-runner/Containerfile |
| 67 | + labels: ${{ steps.metadata.outputs.labels }} |
| 68 | + load: ${{ steps.image_export.outputs.load }} |
| 69 | + push: ${{ steps.image_export.outputs.push }} |
| 70 | + tags: ghcr.io/${{ github.repository_owner }}/buildah-action-runner:${{ steps.version_tag.outputs.tag }} |
| 71 | + - name: Smoke Test Image |
| 72 | + run: | |
| 73 | + docker run --rm ghcr.io/${{ github.repository_owner }}/buildah-action-runner:${{ steps.version_tag.outputs.tag }} bash -lc ' |
| 74 | + buildah --version |
| 75 | + curl --version |
| 76 | + jq --version |
| 77 | + node --version |
| 78 | + ' |
0 commit comments