Skip to content

chore: Update EEA Files #460

chore: Update EEA Files

chore: Update EEA Files #460

Workflow file for this run

# SPDX-FileCopyrightText: © Vegard IT GmbH (https://vegardit.com) and contributors
# SPDX-FileContributor: Sebastian Thomschke (https://sebthom.de), Vegard IT GmbH (https://vegardit.com)
# SPDX-License-Identifier: EPL-2.0
# SPDX-ArtifactOfProjectHomePage: https://github.com/vegardit/no-npe
#
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Build
on:
push:
branches-ignore: # build all branches except:
- 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR)
tags-ignore: # don't build tags
- '**'
paths-ignore:
- '**/*.adoc'
- '**/*.md'
- '.github/*.yml'
pull_request:
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
inputs:
additional_maven_args:
description: 'Additional Maven Args'
required: false
default: ''
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
concurrency: ci-${{ github.ref }}
steps:
- name: Show environment variables
run: env | sort
- name: Git Checkout
uses: actions/checkout@v4 # https://github.com/actions/checkout
- name: Set up JDK 11
uses: actions/setup-java@v3 # https://github.com/actions/setup-java
with:
distribution: temurin
java-version: 11
- run: echo "JAVA11_HOME=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up JDK 17
uses: actions/setup-java@v3 # https://github.com/actions/setup-java
with:
distribution: temurin
java-version: 17
- run: echo "JAVA17_HOME=$JAVA_HOME" >> $GITHUB_ENV
- name: "Cache: Local Maven Repository"
uses: actions/cache@v3
with:
path: |
~/.m2/repository
!~/.m2/**/*SNAPSHOT*
key: ${{ runner.os }}-mvnrepo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-mvnrepo-
- name: Set up Maven
uses: stCarolas/[email protected]
with:
maven-version: 3.9.5
- name: Test with Maven
id: maven-test
if: ${{ github.ref_name != 'main' }}
run: |
bash .ci/build.sh ${{ github.event.inputs.additional_maven_args }}
- name: Prepare Maven Snapshots Repo
if: ${{ github.ref_name == 'main' }}
run: |
set -eux
cd /tmp
github_repo_url="https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}/"
if curl --output /dev/null --silent --head --fail "$github_repo_url/tree/mvn-snapshots-repo"; then
git clone https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}/ --single-branch --branch mvn-snapshots-repo mvn-snapshots-repo
cd mvn-snapshots-repo
# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git reset --hard HEAD^ # revert previous commit
else
git clone https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}/ mvn-snapshots-repo
cd mvn-snapshots-repo
git checkout --orphan mvn-snapshots-repo
git rm -rf .
cat <<EOF > index.html
<!DOCTYPE html>
<html>
<head>
<title>${{ github.repository }} - Maven Snapshots Repo</title>
</head>
<body>
<h1>${{ github.repository }} - Maven Snapshots Repo</h1>
</body>
</html>
EOF
git add index.html
# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -am "Initialize Maven Snapshots Repo"
fi
- name: Build with Maven
id: maven-build
if: ${{ github.ref_name == 'main' }}
env:
MAY_CREATE_RELEASE: true
SIGN_KEY: ${{ secrets.GPG_SIGN_KEY }}
SIGN_KEY_PASS: ${{ secrets.GPG_SIGN_KEY_PWD }}
SONATYPE_OSSRH_USER: ${{ secrets.SONATYPE_OSSRH_USER }}
SONATYPE_OSSRH_USER_TOKEN: ${{ secrets.SONATYPE_OSSRH_USER_TOKEN }}
run: |
set -eu
# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
bash .ci/build.sh \
${{ github.event.inputs.additional_maven_args }} \
-DaltSnapshotDeploymentRepository=temp-snapshots-repo::default::file:///tmp/mvn-snapshots-repo
- name: Update Maven Snapshots Repo
if: ${{ github.ref_name == 'main' }}
run: |
cd /tmp/mvn-snapshots-repo
if [[ $(git -C . ls-files -o -m -d --exclude-standard | wc -l) -gt 0 ]]; then
git add --all
git commit -am "Deploy snapshot version"
git push origin mvn-snapshots-repo --force
fi
dependabot-pr-auto-merge:
needs: build
if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1 # https://github.com/dependabot/fetch-metadata/
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: |
${{
(
steps.dependabot-metadata.outputs.package-ecosystem == 'github-actions' &&
steps.metadata.outputs.update-type == 'version-update:semver-major'
) || (
steps.dependabot-metadata.outputs.package-ecosystem == 'maven' &&
steps.metadata.outputs.update-type == 'version-update:semver-minor'
)
}}
run: |
gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}