Skip to content

Commit

Permalink
Add support for pushing images
Browse files Browse the repository at this point in the history
  • Loading branch information
markpatton committed Dec 13, 2023
1 parent 2013126 commit 268617a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Release artifact will be pushed to Sonatype, which is synced to Maven Central
# Build artifacts get pushed to Sonatype and non-SNAPSHOT versions are then
# auto-synced to Maven Central
# auto-synced to Maven Central.
#
# If images are given (separated by spaces), then they are assumed to be produced by
# Maven and have release and dev tags.
#
# Various secrets are needed to do the release.
#
Expand Down Expand Up @@ -33,13 +36,18 @@ on:
description: 'Next dev version'
required: true
type: string
images:
description: 'Images to push'
required: false
type: string

jobs:
release:
runs-on: ubuntu-latest
env:
RELEASE: ${{ inputs.releaseversion }}
NEXT: ${{ inputs.nextversion }}
IMAGES: ${{ inputs.images }}
steps:
- name: Checkout latest code
uses: actions/checkout@v3
Expand Down Expand Up @@ -87,6 +95,23 @@ jobs:
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Login to GHCR
if: github.event_name == 'workflow_call' && github.event.inputs.images != ''
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Docker image to GHCR
if: github.event_name == 'workflow_call' && github.event.inputs.images != ''
run: |
for name in $IMAGES
do
echo docker push $name:$RELEASE
echo docker push $name:$NEXT
done
- name: Push the commits and tags
run: |
echo git push origin
Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
name: "Publish: manual OR automatic snapshot"

# If images are given (separated by spaces), then they are assumed to be produced by
# Maven and have release and dev tags.

on:
workflow_call:
workflow_dispatch:
workflow_call:
inputs:
images:
description: 'Images to push'
required: false
type: string
push:
branches:
- 'main'
Expand Down Expand Up @@ -38,3 +46,19 @@ jobs:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Login to GHCR
if: github.event_name == 'workflow_call' && github.event.inputs.images != ''
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Docker image to GHCR
if: github.event_name == 'workflow_call' && github.event.inputs.images != ''
run: |
for name in ${{ inputs.images }}
do
echo docker push $name:$VERSION
done

0 comments on commit 268617a

Please sign in to comment.