From a2befaa6a8fd7f9252fb5b4041bc8c0557d28cd4 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:57:16 -0700 Subject: [PATCH] test that trigger step is skipped but workflow succeeds --- .github/workflows/trigger_main.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/trigger_main.yml b/.github/workflows/trigger_main.yml index c29bb22..6149035 100644 --- a/.github/workflows/trigger_main.yml +++ b/.github/workflows/trigger_main.yml @@ -4,7 +4,7 @@ on: push: branches: - develop - - main_v** + - 'main_v[0-9]+.[0-9]+' - main paths-ignore: - 'docs/**' @@ -23,15 +23,15 @@ jobs: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - uses: actions/checkout@v4 + # get the develop branch of METplus to get the latest component version script - uses: actions/checkout@v4 with: repository: 'dtcenter/METplus' ref: 'develop' path: 'METplus' - - run: ls $GITHUB_WORKSPACE - id: get_version run: | - version=$(python3 -c "from component_name import __version__; print(__version__)") + version=$(cut -d "/" -f3 <<< "${GITHUB_REF}") echo "version=${version}" >> $GITHUB_OUTPUT - id: get_metplus_branch run: | @@ -42,15 +42,17 @@ jobs: cmd="$GITHUB_WORKSPACE/METplus/metplus/component_versions.py -i METplotpy -v ${version} -o METplus -f main_v{X}.{Y}" echo $cmd metplus_branch=$($cmd) - if [ -z "$(git -C $GITHUB_WORKSPACE/METplus branch -l ${metplus_branch} --format '%(refname:short)')" ]; then + if [ -z "$(git -C $GITHUB_WORKSPACE/METplus branch -l ${metplus_branch})" ]; then echo "METplus branch ${metplus_branch} does not exist yet" - exit 1 + metplus_branch=none fi echo "metplus_branch=${metplus_branch}" >> $GITHUB_OUTPUT - - run: | + - if: ( steps.get_metplus_branch.outputs.metplus_branch != 'none' ) + run: | metplus_branch=${{ steps.get_metplus_branch.outputs.metplus_branch }} echo "Triggering workflow dispatch of ${metplus_branch}" -# - uses: actions/github-script@v7 +# - if: ( steps.get_metplus_branch.outputs.metplus_branch != 'none' ) +# uses: actions/github-script@v7 # with: # github-token: ${{ secrets.METPLUS_BOT_TOKEN }} # script: | @@ -58,7 +60,7 @@ jobs: # owner: 'dtcenter', # repo: 'METplus', # workflow_id: 'testing.yml', -# ref: 'develop', +# ref: ${{ steps.get_metplus_branch.outputs.metplus_branch }}, # inputs: { # repository: '${{ github.repository }}', # ref: '${{ github.ref }}',