Update docker-image.yml #18
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 docker and publish to org and publish maven package | |
on: | |
push: | |
branches: | |
- 'main' | |
env: | |
GITHUB_ACTOR: ${{github.actor}} | |
GITHUB_TOKEN: ${{github.token}} | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up JDK 17 | |
uses: actions/[email protected] | |
with: | |
java-version: 17 | |
distribution: 'adopt' | |
- name: generate settings.xml for maven builds | |
uses: whelk-io/maven-settings-xml-action@v21 | |
with: | |
repositories: > | |
[ | |
{ | |
"id": "github", | |
"name": "github", | |
"url": "https://maven.pkg.github.com/Music-Web-Micro-service/*", | |
"releases": { | |
"enabled": "true", | |
"updatePolicy": "always", | |
"checksumPolicy": "fail" | |
}, | |
"snapshots": { | |
"enabled": "false", | |
"updatePolicy": "always", | |
"checksumPolicy": "fail" | |
} | |
}, | |
{ | |
"id": "central", | |
"name": "central", | |
"url": "https://repo1.maven.org/maven2", | |
"releases": { | |
"enabled": "true", | |
"updatePolicy": "always", | |
"checksumPolicy": "fail" | |
}, | |
"snapshots": { | |
"enabled": "false", | |
"updatePolicy": "always", | |
"checksumPolicy": "fail" | |
} | |
} | |
] | |
servers: > | |
[ | |
{ | |
"id": "github", | |
"username": "${env.GITHUB_ACTOR}", | |
"password": "${env.GITHUB_TOKEN}", | |
"configuration": { | |
"httpConfiguration": { | |
"all": { | |
"usePreemptive": "true" | |
} | |
} | |
} | |
} | |
] | |
# - name: Log in to GitHub Packages | |
# run: echo "${{ env.GITHUB_TOKEN }}" | gh auth login --with-token | |
# - name: mvn permssion | |
# run: chmod +x ./mvnw | |
- name: Publish to GitHub Packages | |
run: ./mvnw deploy -Dmaven.test.skip=true | |
env: | |
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
registry: ${{env.REGISTRY}} | |
username: ${{env.GITHUB_ACTOR}} | |
password: ${{env.GITHUB_TOKEN}} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{env.REGISTRY}}/${{env.IMAGE_NAME}} | |
tags: | | |
main | |
latest | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |