Try to do a tag #1
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: Reusable tagged release deploy | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
changelist: | ||
description: 'patch and pre-release metadata' | ||
required: true | ||
default: '.0-alpha.1' | ||
workflow_call: | ||
inputs: | ||
changelist: | ||
description: 'patch and pre-release metadata' | ||
required: true | ||
type: string | ||
default: '.0-alpha.1' | ||
dockerize: | ||
description: 'Whether to dockerize' | ||
required: false | ||
type: boolean | ||
default: false | ||
dockerTagPrefix: | ||
description: 'Prefix for Docker tag, required if dockerize is true' | ||
required: false | ||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
# Should only release tags | ||
# TODO: should only release tags where the required status checks are passing | ||
# UNCOMMENT THIS FOR PR REVIEW! | ||
# if: startsWith(github.ref, 'refs/tags/') | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# Step that does that actual cache save and restore | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: install git secrets | ||
run: | | ||
wget --no-verbose -O git-secrets-1.3.0.tar.gz https://github.com/awslabs/git-secrets/archive/1.3.0.tar.gz | ||
tar -zxf git-secrets-1.3.0.tar.gz | ||
cd git-secrets-1.3.0 | ||
sudo make install | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17.0.4+8' | ||
distribution: 'adopt' | ||
- name: Store Maven project version | ||
run: echo "maven_project_version=$(mvn help:evaluate -Dexpression=project.version -Dchangelist=${{ github.event.inputs.changelist }} -q -DforceStdout)" >> $GITHUB_ENV | ||
- name: Read exported variable | ||
run: | | ||
echo "${{ env.maven_project_version }}" | ||
- name: Deploy with mvnw | ||
run: | | ||
git config --global user.email "${{ github.actor }}" | ||
git config --global user.name "${{ github.actor }}" | ||
# Do not submit this for a PR | ||
./mvnw --batch-mode clean install -ntp -s .github/collab-mvn-settings.xml -DskipTests -Dchangelist=${{ github.event.inputs.changelist }} | ||
env: | ||
COLLAB_DEPLOY_TOKEN: ${{ secrets.COLLAB_DEPLOY_TOKEN }} | ||
- name: Login to Quay.io | ||
if: ${{ inputs.dockerize && inputs.dockerTagPrefix != ''}} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USER }} | ||
password: ${{ secrets.QUAY_TOKEN }} | ||
- name: Set Docker tag name | ||
if: ${{ inputs.dockerize && inputs.dockerTagPrefix != ''}} | ||
run: | ||
DOCKER_TAG=${GITHUB_REF##refs/tags/} | ||
if [ $GITHUB_REF == $DOCKER_TAG ]; then | ||
# If this isn't a tag, it must be a branch | ||
DOCKER_TAG=${GITHUB_REF##refs/heads/} | ||
fi | ||
echo "DOCKER_TAG=${{dockerTagPrefix}}:${DOCKER_TAG//\//_}" >> $GITHUB_ENV | ||
- name: Dockerize | ||
if: ${{ inputs.dockerize && inputs.dockerTagPrefix != ''}} | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ env.DOCKER_TAG }} |