Skip to content

Use GITHUB_TOKEN

Use GITHUB_TOKEN #902

Workflow file for this run

name: CI
on:
push:
branches:
- main
paths:
- src/**
- pom.xml
- .github/workflows/ci.yml
pull_request:
branches:
- main
paths:
- src/**
- pom.xml
- .github/workflows/ci.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
cache: 'maven'
- name: mvn test
env:
_JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
run: ./mvnw -V --no-transfer-progress test
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: target
build_jvm_image:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
cache: 'maven'
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
path: target
- name: build image (JVM)
run: |
./mvnw -V --no-transfer-progress spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=ghcr.io/${{ github.repository }}:jvm
- name: docker push (JVM)
if: github.ref == 'refs/heads/main'
env:
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKER_REGISTRY: ghcr.io
run: |
mkdir -p ~/.docker
cat <<EOF > ~/.docker/config.json
{"auths":{"${DOCKER_REGISTRY}":{"username":"${DOCKER_USERNAME}","password":"${DOCKER_PASSWORD}"}}}
EOF
docker push ghcr.io/${{ github.repository }}:jvm
docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository }}:jvm
build_native_image:
if: github.ref == 'refs/heads/skip'
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
cache: 'maven'
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
path: target
- name: build image (Native)
run: ./mvnw -V --no-transfer-progress -Pnative clean spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=ghcr.io/${{ github.repository }}:native
- name: docker push (Native)
env:
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKER_REGISTRY: ghcr.io
run: |
set -e
mkdir -p ~/.docker
cat <<EOF > ~/.docker/config.json
{"auths":{"${DOCKER_REGISTRY}":{"username":"${DOCKER_USERNAME}","password":"${DOCKER_PASSWORD}"}}}
EOF
docker push ghcr.io/${{ github.repository }}:native