maven-package #26
Workflow file for this run
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: maven-package | |
# run manually | |
#on: workflow_dispatch | |
on: | |
push: | |
branches: | |
- '*' | |
tags: | |
- '1.*' | |
jobs: | |
helloworld: | |
# https://stackoverflow.com/a/70448851/1943126 | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions | |
# or ... | |
#permissions: write-all | |
permissions: | |
actions: read | |
checks: read | |
# needed for creating a release! | |
contents: write | |
repository-projects: read | |
#pull-requests: read | |
#security-events: read | |
statuses: read | |
runs-on: ubuntu-20.04 | |
env: | |
{} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# note: for private submodules we need a fine-grained access token (default token only covers top-level repo) | |
# see https://github.com/orgs/community/discussions/25516 | |
submodules: 'true' | |
# access token (fine-grained PAT) with (extra) read permissions on private submodules | |
token: ${{ secrets.ACCESS_TOKEN }} | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: 'maven' | |
- run: ls -hal | |
- run: env | sort | |
- run: ls -hal scripts | |
# see variables on available contexts (https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) | |
- run: >- | |
echo "Github Ref: ${{ github.ref }}" | |
- run: uname -a | |
- run: whoami | |
build_image: | |
runs-on: ubuntu-20.04 | |
if: >- | |
github.ref_type == 'tag' | |
needs: # make dependent on succesfull completion of another job | |
- helloworld | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
token: ${{ secrets.ACCESS_TOKEN }} | |
- id: get_commit_ids | |
run: |- | |
set -x | |
echo short_commit=$(cut -b 1-7 <<<$GITHUB_SHA) >> $GITHUB_OUTPUT | |
echo scripts_short_commit=$(git submodule status scripts | awk '{substr($1,1,7)}') >> $GITHUB_OUTPUT | |
- run: |- | |
echo ${{ steps.get_commit_ids.outputs.short_commit }} | |
echo ${{ steps.get_commit_ids.outputs.scripts_short_commit }} | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
driver: docker | |
- uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# https://github.com/docker/bake-action (see docker-bake.hcl) | |
- uses: docker/bake-action@v4 | |
with: | |
push: true | |
# override build args and/or tags, see: | |
# - https://github.com/docker/bake-action?tab=readme-ov-file#customizing | |
# - https://docs.docker.com/reference/cli/docker/buildx/bake/#set | |
# - https://github.com/docker/buildx/issues/901 | |
set: | | |
default.args.git_url=${{ github.event.repository.url }} | |
default.args.git_commit=${{ github.sha }} | |
default.args.git_tags=${{ github.ref_name }} | |
default.args.git_build_time=${{ github.event.head_commit.timestamp }} | |
default.tags=ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
- name: Inspect image | |
run: >- | |
docker inspect ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
- name: Test run image | |
run: >- | |
docker run --rm ghcr.io/${{ github.repository }}:${{ github.ref_name }} |