|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + image: |
| 8 | + description: "Docker image name and tag" |
| 9 | + required: true |
| 10 | + default: "i386-debian-full" |
| 11 | + publish_tag: |
| 12 | + description: "ghcr.io TAG" |
| 13 | + required: false |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + packages: write |
| 18 | + |
| 19 | +env: |
| 20 | + REGISTRY_IMAGE: ghcr.io/${{ github.repository }} |
| 21 | + |
| 22 | +jobs: |
| 23 | + |
| 24 | + build: |
| 25 | + name: Build |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 1 |
| 32 | + |
| 33 | + - name: Build |
| 34 | + id: build |
| 35 | + run: | |
| 36 | + image="$(echo ${{ inputs.image }} | tr -d '[:space:]')" |
| 37 | + echo "image=$image" >> "$GITHUB_OUTPUT" |
| 38 | + echo "Building: $image" |
| 39 | + |
| 40 | + cd tools/docker/debian |
| 41 | + docker build . --platform linux/386 -t "$image" . |
| 42 | + - name: Export image |
| 43 | + id: export |
| 44 | + run: | |
| 45 | + image='${{ steps.build.outputs.image }}' |
| 46 | + output_fn="$(echo "$image" | tr ':' '_')" |
| 47 | + echo "output_fn=$output_fn" >> "$GITHUB_OUTPUT" |
| 48 | + docker save "$image" -o '${{ runner.temp }}/image.tar' |
| 49 | + sha256sum '${{ runner.temp }}/image.tar' > '${{ runner.temp }}/image.tar.sha256' |
| 50 | + - name: Upload artifact |
| 51 | + continue-on-error: true |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: ${{ steps.export.outputs.output_fn }} |
| 55 | + path: | |
| 56 | + ${{ runner.temp }}/image.tar |
| 57 | + ${{ runner.temp }}/image.tar.sha256 |
| 58 | + compression-level: 9 |
| 59 | + retention-days: 1 |
| 60 | + |
| 61 | + - name: Push to registry |
| 62 | + if: ${{ inputs.publish_tag != '' }} |
| 63 | + run: | |
| 64 | + image="${{ steps.build.outputs.image }}" |
| 65 | + echo "Pushing: $image" |
| 66 | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin |
| 67 | + docker tag "$image" "${{ env.REGISTRY_IMAGE }}:${{ inputs.publish_tag }}" |
| 68 | + docker push "${{ env.REGISTRY_IMAGE }}:${{ inputs.publish_tag }}" |
| 69 | + echo "Pushed: $image to ghcr.io/${{ github.repository }}:${{ inputs.publish_tag }}" |
0 commit comments