update #55
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 workflow will build a package using Maven and then publish it to GitHub packages when a release is created | |
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path | |
name: Maven CI | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
jobs: | |
build: | |
name: Build on java ${{ matrix.java }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
java: ['8', '11'] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up java ${{ matrix.java }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java }} | |
check-latest: true | |
distribution: 'temurin' | |
server-id: github | |
settings-path: ${{ github.workspace }} | |
- name: Build with Maven | |
run: | | |
echo "<settings><servers><server><id>github</id><username>OWNER</username><password>${GITHUB_TOKEN}</password></server></servers><profiles><profile><id>github</id><properties><altReleaseDeploymentRepository>github::default::https://maven.pkg.github.com/shiyindaxiaojie/eden-demo-cola</altReleaseDeploymentRepository><altSnapshotDeploymentRepository>github::default::https://maven.pkg.github.com/shiyindaxiaojie/eden-demo-cola</altSnapshotDeploymentRepository></properties><repositories><repository><id>github</id><name>GitHub OWNER Apache Maven Packages</name><url>https://maven.pkg.github.com/shiyindaxiaojie/eden-architect</url></repository></repositories></profile></profiles></settings>" > $GITHUB_WORKSPACE/settings.xml | |
chmod +x mvnw | |
./mvnw -ntp clean package -Pgithub,unit-test -e -T 4C -s $GITHUB_WORKSPACE/settings.xml | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Publish to GitHub Packages Apache Maven | |
run: ./mvnw -ntp deploy -Pgithub -DskipTests -e -s $GITHUB_WORKSPACE/settings.xml | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Publish to Docker Hub | |
run: | | |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | |
docker build -f docker/Dockerfile -t $DOCKER_IMAGE:$DOCKER_VERSION-jdk${{ matrix.java }} -t $DOCKER_IMAGE:latest . | |
docker push $DOCKER_IMAGE:$DOCKER_VERSION-jdk${{ matrix.java }} | |
if [ "${{ matrix.java }}" == "11" ]; then | |
docker push $DOCKER_IMAGE:latest | |
fi | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
DOCKER_IMAGE: shiyindaxiaojie/eden-demo-cola | |
DOCKER_VERSION: 1.0.0 |