🐛 Fix label match for exclude; bail if instigator #37
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 | |
on: | |
push: | |
branches: | |
- "main" | |
paths-ignore: | |
- '.gitignore' | |
- 'CODEOWNERS' | |
- 'LICENSE' | |
- '*.md' | |
pull_request: | |
paths-ignore: | |
- '.gitignore' | |
- 'CODEOWNERS' | |
- 'LICENSE' | |
- '*.md' | |
env: | |
JAVA_VERSION: 21 | |
JAVA_DISTRO: temurin | |
GH_BOT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" | |
GH_BOT_NAME: "GitHub Action" | |
GRAALVM_DIST: graalvm-community | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 21 | |
distribution: 'temurin' | |
cache: maven | |
- name: Project metadata | |
id: metadata | |
run: | | |
SNAPSHOT=$(yq '.release.snapshot-version' .github/project.yml) | |
ARTIFACT=$(yq '.build.artifact' .github/project.yml) | |
echo "snapshot=${SNAPSHOT}" >> $GITHUB_OUTPUT | |
echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-single-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-single-buildx | |
- name: Build with Maven | |
run: | | |
./mvnw -B -ntp formatter:validate verify | |
- name: Build and run in native mode | |
id: mvn-native-build | |
env: | |
MAVEN_OPTS: "-Xmx1g" | |
run: | | |
./mvnw -B -ntp verify -DskipTests -DskipFormat \ | |
-Dnative \ | |
-Dquarkus.native.container-build=true \ | |
-Dquarkus.container-image.build=true | |
- name: Update release with snapshot artifact | |
if: ${{ github.event_name == 'push' && github.repository == 'commonhaus/automation' }} | |
id: mvn-release-snapshot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SNAPSHOT: ${{ steps.metadata.outputs.snapshot }} | |
run: | | |
git config user.name ${{ env.GH_BOT_NAME }} | |
git config user.email ${{ env.GH_BOT_EMAIL }} | |
ls -al target | |
AV=${{ steps.metadata.outputs.artifact }}-${{ steps.metadata.outputs.snapshot }}-runner | |
gh release upload "${SNAPSHOT}" --clobber ./target/${AV}.jar#${AV}.jar | |
gh release upload "${SNAPSHOT}" --clobber ./target/${AV}#${AV} | |
echo "Update tag for $SNAPSHOT" | |
git push origin :refs/tags/$SNAPSHOT | |
git tag -f $SNAPSHOT | |
git push --tags | |
echo "Update $SNAPSHOT release" | |
gh release edit "${SNAPSHOT}" -t "${SNAPSHOT}" --prerelease | |
- name: Log in to the Container registry | |
if: ${{ github.event_name == 'push' && github.repository == 'commonhaus/automation' }} | |
uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish OCI (native) | |
if: ${{ github.event_name == 'push' && github.repository == 'commonhaus/automation' }} | |
id: publish-oci | |
env: | |
SNAPSHOT: ${{ steps.metadata.outputs.snapshot }} | |
run: | | |
image="commonhaus/commonhaus-bot:${SNAPSHOT}" | |
docker tag "${image}" "ghcr.io/${image}" | |
docker push "ghcr.io/commonhaus/commonhaus-bot:${SNAPSHOT}" | |
- name: Mark snapshot release as non-draft | |
if: ${{ github.event_name == 'push' && github.repository == 'commonhaus/automation' }} | |
id: update-snapshot-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SNAPSHOT: ${{ steps.metadata.outputs.snapshot }} | |
run: | | |
gh release edit "${SNAPSHOT}" --draft=false | |
gh release view "${SNAPSHOT}" |