DAT-17704 #7508
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: Build Branch SNAPSHOT | |
# concurrent runs for pull requests (both internal and forked) will be canceled when a new run is triggered. | |
# It does not specifically target or exclude the 'master' branch; it cancels concurrent runs whenever a pull request is triggered. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
on: | |
workflow_dispatch: | |
pull_request_target: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- labeled | |
push: | |
branches: | |
- github-action-** | |
paths-ignore: | |
- '**.md' | |
jobs: | |
setup: | |
name: Setup | |
runs-on: ubuntu-22.04 | |
outputs: | |
timeStamp: ${{ steps.get-timestamp.outputs.timestamp }} | |
thisBranchName: ${{ steps.get-branch-name.outputs.thisBranchName }} | |
latestMergeSha: ${{ steps.get-sha.outputs.latestMergeSha }} | |
setupSuccessful: "true" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.event.after}} | |
- name: Get Latest Merge Commit SHA | |
id: get-sha | |
run: | | |
latest_merge_sha=`(git rev-parse HEAD)` | |
echo "latestMergeSha=${latest_merge_sha}" >> $GITHUB_OUTPUT | |
- name: Get Timestamp | |
id: get-timestamp | |
run: | | |
timeStamp=$(date +'%Y-%m-%d %H:%M:%S %Z') | |
echo "timestamp=${timeStamp}" >> $GITHUB_OUTPUT | |
- name: Get Current BranchName | |
id: get-branch-name | |
run: | | |
# this logic checks if the branch is from a forked repository PR or not. Where -n is the inverse of -z (not empty) | |
if [ -n "${GITHUB_HEAD_REF}" ]; | |
then | |
branch_name=${GITHUB_HEAD_REF} | |
else | |
branch_name=${{ github.ref_name }} | |
fi | |
modified_branch_name=`(echo $branch_name | tr '/' '_')` | |
echo "thisBranchName=$modified_branch_name" >> $GITHUB_OUTPUT | |
build: | |
name: Build & Package | |
runs-on: ubuntu-22.04 | |
needs: setup | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.event.after}} | |
- name: Set up Java for publishing to GitHub Repository | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'maven' | |
server-id: liquibase | |
# Version artifact based off of branch and commit SHA. | |
- name: Version Artifact | |
run: | | |
./mvnw versions:set "-DnewVersion=${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT" | |
#./mvnw versions:set "-DnewVersion=${{ inputs.branchName }}-SNAPSHOT" | |
# Publish to GitHub Packages | |
- name: Publish package | |
run: | | |
./mvnw -B clean deploy -pl '!liquibase-dist' -DskipTests=true "-Dbuild.repository.owner=liquibase" "-Dbuild.repository.name=liquibase" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.latestMergeSha }}" "-Dbuild.timestamp=${{ needs.setup.outputs.timeStamp }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |