java maven hint #21
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
name: Build and Push Docker Image | |
on: | |
push: | |
branches: | |
- docker | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: test curl | |
run: | | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/users/slow-groovin/packages/maven/com.github.action.test.github-package-upload-config | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'liberica' | |
# server-password: MY_GH_SECRET_TOKEN #with test, this will not work for when maven project has a dependency of same/other github repo's packages | |
cache: maven | |
- name: run echo something | |
run: | | |
echo github.workspace:${{ github.workspace }} | |
echo github.repository:${{ github.repository }} | |
echo github.ref:${{ github.ref }} | |
echo version:$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout ) | |
echo artifactId:$(mvn help:evaluate -Dexpression=project.artifactId -DforceStdout -q ) | |
echo GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }} | |
echo MY_GH_SECRET_TOKEN:${{ secrets.MY_GH_SECRET_TOKEN }} | |
cat ~/.m2/settings.xml | |
- name: Build with Maven | |
run: cd java && mvn -B package -P github -X | |
env: | |
GITHUB_TOKEN: ${{ secrets.MY_GH_SECRET_TOKEN }} # only this will not work for when maven project has a dependency of same/other github repo's packages | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64 | |
context: ./java | |
push: true | |
tags: ghcr.io/${{ github.repository }}:latest | |