Skip to content

Commit

Permalink
try more idiomatic way of building the archive for PR workflow runs
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Mart committed Feb 13, 2024
1 parent c02f8c2 commit 5ec353b
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions .github/workflows/builder-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,27 @@ jobs:
ubuntu-builder:
name: psibase-builder-ubuntu-${{ inputs.ubuntu_version }}
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0

- name: Free up runner space
run: bash ${GITHUB_WORKSPACE}/.github/scripts/free-disk-space.sh

- name: Preparation
id: prep
run: |
OWNER="${{ github.repository_owner }}"
IMAGE="psibase-builder-ubuntu-${{ inputs.ubuntu_version }}"
if [[ "${{ inputs.is_pr }}" == "true" ]]; then
REGISTRY="localhost:5000"
TAG="latest"
else
REGISTRY="ghcr.io"
TAG="${{ github.sha }}"
fi
REGISTRY="ghcr.io"
TAG="${{ github.sha }}"
TAGS="${REGISTRY}/${OWNER}/${IMAGE}:${TAG}"
echo "tags=${TAGS,,}" >> $GITHUB_OUTPUT
- name: Building ${{ steps.prep.outputs.tags }}
run: true

- name: (PR only) - Config docker buildx network
if: ${{ inputs.is_pr }}
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
driver-opts: network=host

- name: Login in to registry
if: ${{ !inputs.is_pr }}
uses: docker/login-action@v2
Expand All @@ -71,6 +52,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & Publish Image
if: ${{ !inputs.is_pr }}
uses: docker/build-push-action@v4
with:
context: .
Expand All @@ -79,14 +61,18 @@ jobs:
tags: ${{ steps.prep.outputs.tags }}
platforms: linux/amd64
outputs: type=image,annotation-index.org.opencontainers.image.description=Psibase build environment based on Ubuntu ${{ inputs.ubuntu_version }}

- name: (PR only) - Save docker image to archive
- name: (PR Only) - Build image archive
if: ${{ inputs.is_pr }}
run: |
docker pull ${{ steps.prep.outputs.tags }}
docker save ${{ steps.prep.outputs.tags }} -o builder-${{ inputs.ubuntu_version }}-image.tar
uses: docker/build-push-action@v4
with:
context: .
file: docker/ubuntu-${{ inputs.ubuntu_version }}-builder.Dockerfile
tags: ${{ steps.prep.outputs.tags }}
platforms: linux/amd64
outputs: type=docker,dest=builder-${{ inputs.ubuntu_version }}-image.tar

- name: (PR only) - Upload docker image archive
- name: (PR only) - Upload image archive as artifact
if: ${{ inputs.is_pr }}
uses: actions/upload-artifact@v4
with:
Expand Down

0 comments on commit 5ec353b

Please sign in to comment.