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

GH workflow to publish images for PRs labeled 'publish' #1540

Merged
merged 1 commit into from
Aug 28, 2024
Merged
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
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@ on:
- dev-[0-9]+.[0-9]+.[0-9]+
tags:
- v*
pull_request:
types:
# publish images for PRs labeled "publish" whenever changed/labeled
[opened, reopened, synchronize, labeled]
workflow_dispatch:

env:
REGISTRY: ghcr.io
OWNER: nasa-ammos
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
SHOULD_PUBLISH_IMAGES: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'publish') }}
SHOULD_PUBLISH_DEPLOYMENT: ${{ (github.event_name != 'pull_request') }}

jobs:
init:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
# set these as outputs to make available later, since `env` context isn't available in `jobs.if`
SHOULD_PUBLISH_IMAGES: ${{ env.SHOULD_PUBLISH_IMAGES }}
SHOULD_PUBLISH_DEPLOYMENT: ${{ env.SHOULD_PUBLISH_DEPLOYMENT }}
steps:
- uses: actions/checkout@v4

Expand All @@ -34,6 +44,7 @@ jobs:
containers:
runs-on: ubuntu-latest
needs: init
if: needs.init.outputs.SHOULD_PUBLISH_IMAGES == 'true'
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -63,6 +74,9 @@ jobs:
file: docker/Dockerfile.postgres
name: ${{ matrix.components.image }}
steps:
- name: Log SHOULD_PUBLISH_IMAGES
run: echo ${{ needs.init.outputs.SHOULD_PUBLISH_IMAGES }}

- uses: actions/checkout@v4

- uses: actions/setup-java@v4
Expand Down Expand Up @@ -119,6 +133,7 @@ jobs:
scan:
runs-on: ubuntu-latest
needs: containers
if: needs.init.outputs.SHOULD_PUBLISH_IMAGES == 'true'
strategy:
matrix:
image:
Expand Down Expand Up @@ -155,6 +170,7 @@ jobs:
name: gradle publish
runs-on: ubuntu-latest
needs: init
if: needs.init.outputs.SHOULD_PUBLISH_DEPLOYMENT == 'true'
permissions:
contents: read
packages: write
Expand Down
Loading