Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share local Docker images between jobs when running the CI pipeline in a PR #192

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions .github/workflows/alpine-mainline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,19 @@ jobs:
context: "{{ defaultContext }}:mainline/alpine-slim"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
# push: ${{ github.event_name != 'pull_request' }}
outputs: ${{ github.event_name != 'pull_request' && 'type=registry' || 'type=oci,dest=/tmp/nginxslim.tar' }}
# cache-from: type=gha,scope=alpine-slim
# cache-to: type=gha,mode=min,scope=alpine-slim

- name: Upload Docker build artifact during local builds
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: nginxslim
path: /tmp/nginxslim.tar
retention-days: 1

- name: Sign Docker Hub Manifest
if: ${{ github.event_name != 'pull_request' }}
run: |
Expand Down Expand Up @@ -198,6 +207,18 @@ jobs:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Download artifact
if: ${{ github.event_name == 'pull_request' }}
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: nginxslim
path: /tmp

- name: Load image
if: ${{ github.event_name == 'pull_request' }}
run: |
docker load --input /tmp/nginxslim.tar

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
Expand Down Expand Up @@ -227,10 +248,19 @@ jobs:
context: "{{ defaultContext }}:mainline/alpine"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
# push: ${{ github.event_name != 'pull_request' }}
outputs: ${{ github.event_name != 'pull_request' && 'type=registry' || 'type=oci,dest=/tmp/nginxcore.tar' }}
# cache-from: type=gha,scope=debian-perl
# cache-to: type=gha,mode=min,scope=debian-perl

- name: Upload Docker build artifact during local builds
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: nginxcore
path: /tmp/nginxcore.tar
retention-days: 1

- name: Sign Docker Hub Manifest
if: ${{ github.event_name != 'pull_request' }}
run: |
Expand Down Expand Up @@ -334,6 +364,18 @@ jobs:
type=raw,value=alpine-perl
type=raw,value=alpine${{ needs.version.outputs.distro }}-perl

- name: Download artifact
if: ${{ github.event_name == 'pull_request' }}
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: nginxcore
path: /tmp

- name: Load image
if: ${{ github.event_name == 'pull_request' }}
run: |
docker load --input /tmp/nginxcore.tar

- name: Build and push NGINX mainline perl Alpine image to Amazon ECR Public Gallery, Docker Hub, GitHub Container Registry, and Quay
id: build
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
Expand All @@ -343,6 +385,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
# outputs: ${{ github.event_name != 'pull_request' && 'type=registry' || 'type=oci,dest=/tmp/nginxslim.tar' }}
# cache-from: type=gha,scope=alpine-perl
# cache-to: type=gha,mode=min,scope=alpine-perl

Expand Down