-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix jib image build * publish automatically on main and manually on other branches * add auth for dockerhub public images (because of rate limits) * specify base image add prefix: library
- Loading branch information
Showing
5 changed files
with
68 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: build and publish image | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ "main" ] | ||
|
||
env: | ||
DOCKER_IMAGE_REGISTRY: ghcr.io/${{ github.repository }} | ||
DOCKER_REGISTRY_USERNAME: ${{ github.actor }} | ||
DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
|
||
jobs: | ||
build-and-publish-image: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
checks: write | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
|
||
- name: Set DOCKER_APP_IMAGE for all branches except main | ||
if: github.ref != 'refs/heads/main' | ||
run: echo "DOCKER_APP_IMAGE=$(echo ${{ env.DOCKER_IMAGE_REGISTRY }}:${GITHUB_SHA::7})" >> $GITHUB_ENV | ||
|
||
- name: Set DOCKER_APP_IMAGE for main branch | ||
if: github.ref == 'refs/heads/main' | ||
run: echo "DOCKER_APP_IMAGE=$(echo ${{ env.DOCKER_IMAGE_REGISTRY }}:latest})" >> $GITHUB_ENV | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push image | ||
run: | | ||
./mvnw install \ | ||
-B --no-transfer-progress --file pom.xml \ | ||
-D docker.app.image=${{ env.DOCKER_APP_IMAGE }} \ | ||
-P exec.docker.image \ | ||
-am -pl addondemo.app.image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters