From 268617a38b6984b1130aff91ec455f295db629f0 Mon Sep 17 00:00:00 2001 From: Mark Patton Date: Wed, 13 Dec 2023 12:39:57 -0500 Subject: [PATCH] Add support for pushing images --- .github/workflows/release.yml | 27 ++++++++++++++++++++++++++- .github/workflows/snapshot.yml | 26 +++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7d2aaaa5..482c62e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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. # @@ -33,6 +36,10 @@ on: description: 'Next dev version' required: true type: string + images: + description: 'Images to push' + required: false + type: string jobs: release: @@ -40,6 +47,7 @@ jobs: env: RELEASE: ${{ inputs.releaseversion }} NEXT: ${{ inputs.nextversion }} + IMAGES: ${{ inputs.images }} steps: - name: Checkout latest code uses: actions/checkout@v3 @@ -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 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 52681c0a..a42b2754 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -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' @@ -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