From 5e5e03fedf12da04e97278d9510f0c8cbee932cf Mon Sep 17 00:00:00 2001 From: beckermr Date: Wed, 28 Aug 2024 04:51:40 -0500 Subject: [PATCH] fix: skip at the top --- .github/workflows/relock.yml | 41 +++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/relock.yml b/.github/workflows/relock.yml index ebb8f0190..c257f6fb8 100644 --- a/.github/workflows/relock.yml +++ b/.github/workflows/relock.yml @@ -16,9 +16,29 @@ jobs: shell: bash -leo pipefail {0} steps: + # https://stackoverflow.com/a/73828715/1745538 + - name: skip if PR already exists + id: check + run: | + prs=$(gh pr list \ + --repo "$GITHUB_REPOSITORY" \ + --head 'relock-deps' \ + --base 'master' \ + --json title \ + --jq 'length') + if [[ ${prs} != "0" ]]; then + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "skip=false" >> "$GITHUB_OUTPUT" + fi + env: + GH_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }} + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + if: ${{ steps.check.outputs.skip != 'true' }} - uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1 + if: ${{ steps.check.outputs.skip != 'true' }} with: environment-file: conda-lock.yml environment-name: cf-scripts @@ -26,6 +46,7 @@ jobs: - name: relock id: relock + if: ${{ steps.check.outputs.skip != 'true' }} run: | python autotick-bot/relock_me.py conda-lock.yml > summary.txt { @@ -35,27 +56,9 @@ jobs: } >> "$GITHUB_OUTPUT" rm summary.txt - # https://stackoverflow.com/a/73828715/1745538 - - name: skip if PR already exists - id: check - run: | - prs=$(gh pr list \ - --repo "$GITHUB_REPOSITORY" \ - --head 'relock-deps' \ - --base 'master' \ - --json title \ - --jq 'length') - if [[ ${prs} != "0" ]]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - else - echo "skip=false" >> "$GITHUB_OUTPUT" - fi - env: - GH_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }} - - name: open PR - if: ${{ steps.check.outputs.skip != 'true' }} id: pr + if: ${{ steps.check.outputs.skip != 'true' }} uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6 with: commit-message: relock w/ conda-lock