Only upload builder artifacts from workflow runs triggered after merge #37
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: Generate ubuntu-2204 images | |
env: | |
GITHUB_OUTPUT: "" | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "docker/ubuntu-2204-builder.Dockerfile" | |
- ".github/workflows/ubuntu-2204.yml" | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
- "docker/ubuntu-2204-builder.Dockerfile" | |
- ".github/workflows/ubuntu-2204.yml" | |
workflow_run: | |
workflows: ["Generate tool-config images"] | |
types: [completed] | |
branches: | |
- 'main' | |
jobs: | |
ubuntu-2204-builder: | |
name: psibase-builder-ubuntu-2204 | |
runs-on: ubuntu-latest | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
submodules: false | |
fetch-depth: 0 | |
- name: Preparation | |
id: prep | |
run: | | |
REGISTRY="ghcr.io" | |
IMAGE="${REGISTRY}/${{ github.repository_owner }}/psibase-builder-ubuntu-2204" | |
SHA_TAG="${IMAGE}:${{ github.sha }}" | |
PR_TAG="localhost:5000/pr-psibase-builder-ubuntu-2204:latest" | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
TAGS="${PR_TAG}" | |
else | |
TAGS="${SHA_TAG}" | |
fi | |
echo "tags=${TAGS,,}" >> $GITHUB_OUTPUT | |
- name: Showtag | |
id: showtag | |
run: echo ${{ steps.prep.outputs.tags }} | |
- name: Docker Buildx setup | |
uses: docker/setup-buildx-action@v2 | |
with: | |
buildkitd-flags: --debug | |
- name: Login in to registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build & Publish Image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
file: docker/ubuntu-2204-builder.Dockerfile | |
tags: ${{ steps.prep.outputs.tags }} | |
platforms: linux/amd64 | |
outputs: type=image,annotation-index.org.opencontainers.image.description=Psibase build environment based on Ubuntu 22.04 (amd64) | |
- name: PR exclusive - Save docker image to archive | |
if: github.event_name == 'pull_request' | |
run: | | |
docker save ${{ steps.prep.outputs.tags }} -o temp-pr-image.tar | |
- name: PR exclusive - Upload docker image archive | |
if: github.event_name == 'pull_request' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: base-image | |
path: temp-pr-image.tar | |
psibase-contributor: | |
name: psibase-contributor | |
runs-on: ubuntu-latest | |
needs: ubuntu-2204-builder | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
submodules: false | |
fetch-depth: 0 | |
- name: Preparation | |
id: prep | |
run: | | |
REGISTRY="ghcr.io" | |
IMAGE="${REGISTRY}/${{ github.repository_owner }}/psibase-contributor" | |
TAGS="${IMAGE}:${{ github.sha }},${IMAGE}:latest" | |
echo "tags=${TAGS,,}" >> $GITHUB_OUTPUT | |
- name: Showtag | |
id: showtag | |
run: echo ${{ steps.prep.outputs.tags }} | |
- name: Docker Buildx setup | |
uses: docker/setup-buildx-action@v2 | |
with: | |
buildkitd-flags: --debug | |
- name: Login in to registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: PR exclusive - Download docker image archive | |
if: github.event_name == 'pull_request' | |
uses: actions/download-artifact@v3 | |
with: | |
name: base-image | |
- name: PR exclusive - Install docker image from archive | |
run: | | |
docker load -i temp-pr-image.tar | |
- name: Set PARENT_IMAGE env | |
run: | | |
if [ "${{ github.event_name }}" = "pull_request" ]; then | |
echo "PARENT_IMAGE=pr-ghcr.io/gofractally/psibase-builder-ubuntu-2204:latest" >> $GITHUB_ENV | |
else | |
echo "PARENT_IMAGE=ghcr.io/gofractally/psibase-builder-ubuntu-2204:${{ github.sha }}" >> $GITHUB_ENV | |
fi | |
- name: Build & Publish Image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
build-args: | | |
PARENT_IMAGE=${{ env.PARENT_IMAGE }} | |
file: docker/psibase-contributor.Dockerfile | |
tags: ${{ steps.prep.outputs.tags }} | |
platforms: linux/amd64 | |
outputs: type=image,annotation-index.org.opencontainers.image.description=Psibase development environment |