make it easier to test pull request images #193
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pr_build | |
on: | |
pull_request: | |
paths: | |
- '*' | |
- '*/**' | |
- '!README.md' | |
- '!COPYING.LGPL-3' | |
- '!.gitattributes' | |
- '!.gitignore' | |
types: | |
- opened | |
- reopened | |
- synchronize | |
env: | |
FS_IMAGE: ghcr.io/${{ github.repository }} | |
FS_TAG: 0.0.0-pr${{ github.event.pull_request.number }} | |
# TODO: Move this to repo config | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
pull-requests: write | |
strategy: | |
matrix: | |
platform: | |
- linux/amd64 | |
# - linux/arm64 | |
steps: | |
- name: Set up QEMU | |
id: qemu | |
uses: docker/setup-qemu-action@v1 | |
with: | |
image: tonistiigi/binfmt:latest | |
platforms: all | |
if: matrix.platform == 'linux/arm64' | |
- uses: actions/checkout@v3 | |
- name: extract git sha | |
run: echo "GIT_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
# Reads in .tools-versions and spits out env variables | |
- uses: wistia/[email protected] | |
- uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: earthly/actions-setup@v1 | |
with: { version: "v${{ env.EARTHLY_TOOL_VERSION }}" } | |
- run: | | |
earthly \ | |
--push \ | |
--platform ${{ matrix.platform }} \ | |
+docker-tag \ | |
--GIT_COMMIT=${{ env.GIT_SHA_SHORT }} \ | |
--GIT_TAG=${{ env.FS_TAG }} \ | |
--GOLANG_VERSION=${{ env.GOLANG_TOOL_VERSION }} \ | |
--CI_REGISTRY_IMAGE=${{ env.FS_IMAGE }} | |
- uses: mshick/add-pr-comment@v2 | |
with: | |
message: | | |
Temporary image available at `${{ env.FS_IMAGE }}:${{ env.FS_TAG }}`. |