|
| 1 | +name: Publish DockerImage from Release Branch |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + releaseBranch: |
| 7 | + description: 'Release Branch (releases/mXXX)' |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + publish-image: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + packages: write |
| 16 | + id-token: write |
| 17 | + attestations: write |
| 18 | + env: |
| 19 | + REGISTRY: ghcr.io |
| 20 | + IMAGE_NAME: ${{ github.repository_owner }}/actions-runner |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v5 |
| 24 | + with: |
| 25 | + ref: ${{ github.event.inputs.releaseBranch }} |
| 26 | + |
| 27 | + - name: Compute image version |
| 28 | + id: image |
| 29 | + uses: actions/github-script@v8.0.0 |
| 30 | + with: |
| 31 | + script: | |
| 32 | + const fs = require('fs'); |
| 33 | + const runnerVersion = fs.readFileSync('${{ github.workspace }}/releaseVersion', 'utf8').replace(/\n$/g, ''); |
| 34 | + console.log(`Using runner version ${runnerVersion}`); |
| 35 | + if (!/^\\d+\\.\\d+\\.\\d+$/.test(runnerVersion)) { |
| 36 | + throw new Error(`Invalid runner version: ${runnerVersion}`); |
| 37 | + } |
| 38 | + core.setOutput('version', runnerVersion); |
| 39 | +
|
| 40 | + - name: Setup Docker buildx |
| 41 | + uses: docker/setup-buildx-action@v3 |
| 42 | + |
| 43 | + - name: Log into registry ${{ env.REGISTRY }} |
| 44 | + uses: docker/login-action@v3 |
| 45 | + with: |
| 46 | + registry: ${{ env.REGISTRY }} |
| 47 | + username: ${{ github.actor }} |
| 48 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + - name: Build and push Docker image |
| 51 | + id: build-and-push |
| 52 | + uses: docker/build-push-action@v6 |
| 53 | + with: |
| 54 | + context: ./images |
| 55 | + platforms: | |
| 56 | + linux/amd64 |
| 57 | + linux/arm64 |
| 58 | + tags: | |
| 59 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }} |
| 60 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
| 61 | + build-args: | |
| 62 | + RUNNER_VERSION=${{ steps.image.outputs.version }} |
| 63 | + push: true |
| 64 | + labels: | |
| 65 | + org.opencontainers.image.source=${{github.server_url}}/${{github.repository}} |
| 66 | + org.opencontainers.image.licenses=MIT |
| 67 | + annotations: | |
| 68 | + org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }} |
| 69 | +
|
| 70 | + - name: Generate attestation |
| 71 | + uses: actions/attest-build-provenance@v3 |
| 72 | + with: |
| 73 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 74 | + subject-digest: ${{ steps.build-and-push.outputs.digest }} |
| 75 | + push-to-registry: true |
0 commit comments