chore(deps): update plugin org.danilopianini.gradle-java-qa to v1.103.0 (exercises) #2410
Workflow file for this run
This file contains hidden or 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: test-and-deploy | |
on: | |
push: | |
branches-ignore: | |
- renovate/** | |
pull_request: | |
jobs: | |
tests: | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-24.04 | |
# - windows | |
- macos-14 | |
runs-on: ${{ matrix.os }} | |
concurrency: | |
group: ${{ github.workflow }}-test-${{ matrix.os }}-${{ github.event.number || github.ref }} | |
steps: | |
- name: Setup Java | |
uses: actions/setup-java@v4.7.0 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: Setup WSL | |
if: runner.os == 'Windows' | |
uses: Vampire/setup-wsl@v5.0.0 | |
with: | |
distribution: Ubuntu-22.04 | |
- name: Configure WSL | |
if: runner.os == 'Windows' | |
shell: wsl-bash {0} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y openjdk-21-jre-headless | |
- name: Checkout | |
uses: actions/checkout@v4.2.2 | |
- name: Get branch names | |
id: branch-names | |
uses: tj-actions/branch-names@v8.0.1 | |
- name: Tests | |
env: | |
BRANCH: ${{ steps.branch-names.outputs.current_branch }} | |
run: ./tests.main.kts | |
prepare-deliveries: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.deliveries.outputs.matrix }} | |
steps: | |
- name: Setup Java | |
uses: actions/setup-java@v4.7.0 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: Compute ref | |
id: ref | |
run: | | |
ruby -e '\ | |
if "${{ github.event_name }}" == "push" && "${{ github.event.ref }}".end_with?("/master") then | |
puts "::set-output name=ref::${{ github.event.after }}" | |
else | |
puts "::set-output name=ref::master" | |
end | |
' | |
- name: Checkout | |
uses: actions/checkout@v4.2.2 | |
with: | |
fetch-depth: 0 | |
ref: ${{ steps.ref.outputs.ref }} | |
submodules: recursive | |
- name: Prepare deliverable packages | |
id: deliveries | |
run: ./deployer.main.kts | |
- name: Tar files | |
run: tar -cvf build.tar build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4.6.1 | |
with: | |
name: build | |
path: build.tar | |
delivery: | |
needs: | |
- tests # Don't deliver if testing fails | |
- prepare-deliveries | |
runs-on: ubuntu-latest | |
if: >- | |
!github.event.repository.fork | |
&& ( | |
github.event_name != 'pull_request' | |
|| github.event.pull_request.head.repo.full_name == github.repository | |
) | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.prepare-deliveries.outputs.matrix) }} | |
max-parallel: 1 | |
concurrency: | |
group: ${{ github.workflow }}-delivery-${{ matrix.type }}-${{ matrix.ref }}-${{ matrix.target }}-${{ matrix.owner }}-${{ matrix.repo }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: false | |
steps: | |
- name: Checkout the local repo | |
if: matrix.type == 'repo' | |
uses: actions/checkout@v4.2.2 | |
- name: Checkout the target repo if it exists, initialize if needed | |
if: matrix.type == 'repo' | |
run: | | |
git clone https://${{ secrets.DEPLOYMENT_TOKEN }}@github.com/${{ matrix.owner }}/${{ matrix.repo }} target | |
cd target | |
git checkout ${{ matrix.ref }} || git checkout ${{ matrix.ref }} origin/${{ matrix.ref }} || git checkout -b ${{ matrix.ref }} | |
if ! git rev-parse HEAD &> /dev/null; then | |
echo 'The repository is empty, creating the target branch and adding a first commit' | |
git config user.name 'pianinator[bot]' | |
git config user.email 'noreply@unibo.it' | |
git commit --allow-empty -m 'initialize the repository' | |
fi | |
- name: Check if the branch can release | |
id: can-release | |
run: | | |
echo "can-release=${{endsWith(github.ref, '/master') || endsWith(github.ref, '/exercises')}}" >> $GITHUB_OUTPUT | |
- name: Push the repo | |
if: matrix.type == 'repo' && steps.can-release.outputs.can-release == 'true' | |
working-directory: target | |
run: | | |
git push -u origin ${{ matrix.ref }} | |
- name: Download artifact | |
uses: actions/download-artifact@v4.1.9 | |
with: | |
name: build | |
- name: Unpack | |
run: tar -xf build.tar | |
- name: Deliver an archive | |
if: matrix.type == 'release' && steps.can-release.outputs.can-release == 'true' | |
uses: ncipollo/release-action@v1.16.0 | |
with: | |
allowUpdates: true | |
artifacts: ${{ matrix.target }} | |
owner: ${{ matrix.owner }} | |
repo: ${{ matrix.repo }} | |
replacesArtifacts: true | |
tag: ${{ matrix.ref }} | |
token: ${{ secrets.DEPLOYMENT_TOKEN }} | |
- name: Deliver a branch | |
if: matrix.type == 'repo' && steps.can-release.outputs.can-release == 'true' | |
uses: JamesIves/github-pages-deploy-action@v4.7.3 | |
with: | |
folder: ${{ matrix.target }} | |
token: ${{ secrets.DEPLOYMENT_TOKEN }} | |
branch: ${{ matrix.ref }} | |
repository-name: ${{ matrix.owner }}/${{ matrix.repo }} | |
success: | |
runs-on: ubuntu-24.04 | |
needs: | |
- delivery | |
- tests | |
if: >- | |
always() && ( | |
contains(join(needs.*.result, ','), 'failure') | |
|| !contains(join(needs.*.result, ','), 'cancelled') | |
) | |
steps: | |
- name: Verify that there were no failures | |
run: ${{ !contains(join(needs.*.result, ','), 'failure') }} |