Skip to content

init

init #1

# Example: Using Branch Name as Package Name
# This workflow uses the source branch name as the package name for build and validation
name: Example - Build with Branch Name
on:
pull_request:
branches:
- Release_Source
- main
workflow_dispatch:
env:
PACKAGES_FOLDER: 'packages'
jobs:
# Use branch name as package name
get_package_from_branch:
name: Get Package from Branch Name
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
package-name: ${{ steps.set-matrix.outputs.package-name }}
steps:
- name: Get Branch Name and Create Matrix
id: set-matrix
shell: bash
run: |
# Get the branch name
if [ "${{ github.event_name }}" = "pull_request" ]; then
# For PRs, use the source branch (head ref)
BRANCH_NAME="${{ github.head_ref }}"
else
# For workflow_dispatch, use the current branch
BRANCH_NAME="${{ github.ref_name }}"
fi
echo "Branch name: $BRANCH_NAME"
echo "Using branch name as package name: $BRANCH_NAME"
# Create matrix with the branch name as package
matrix='[{"package":"'"$BRANCH_NAME"'"}]'
echo "matrix=$matrix"
echo "matrix=$matrix" >> $GITHUB_OUTPUT
echo "package-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
# Call the reusable workflow with the branch name as package
build_and_validate:
name: Build and Validate Package
needs: get_package_from_branch
uses: ./.github/workflows/linux/reusable-build-validate.yml

Check failure on line 52 in .github/workflows/example-build-branch-name.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/example-build-branch-name.yml

Invalid workflow file

invalid value workflow reference: workflows must be defined at the top level of the .github/workflows/ directory
with:
project-name: 'Demo-PSQL'
packages-matrix: ${{ needs.get_package_from_branch.outputs.matrix }}
packages-folder: 'packages'
agent-jar-path: '/home/runner/DBmaestroAgent.jar'
use-ssl: 'True'
auth-type: 'DBmaestroAccount'
package-type: 'Regular'
runner: 'dbmaestro-linux'
secrets:
dbmaestro-server: ${{ vars.DBMAESTRO_SERVER }}
dbmaestro-user: ${{ secrets.DBMAESTRO_USER }}
dbmaestro-password: ${{ secrets.DBMAESTRO_PASSWORD }}
# Optional: Post-processing job for PR comments
post_process:
name: Post-Process Results
runs-on: ubuntu-latest
needs: [get_package_from_branch, build_and_validate]
if: always() && github.event_name == 'pull_request'
steps:
- name: Check Results
run: |
echo "Package name: ${{ needs.get_package_from_branch.outputs.package-name }}"
echo "Package matrix: ${{ needs.get_package_from_branch.outputs.matrix }}"
- name: Comment on PR (Success)
if: needs.build_and_validate.result == 'success'
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
-d "{\"body\":\":white_check_mark: **Package Built and Validated Successfully**\n\nPackage: \`${{ needs.get_package_from_branch.outputs.package-name }}\`\n\nReady to merge!\"}"
- name: Comment on PR (Failure)
if: needs.build_and_validate.result == 'failure'
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
-d "{\"body\":\":x: **Package Build or Validation Failed**\n\nPackage: \`${{ needs.get_package_from_branch.outputs.package-name }}\`\n\nPlease check the workflow logs for details.\"}"