From 97d5819fad7c34e18e1d4f96173d01517e154763 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 31 Jul 2024 11:58:13 -0500 Subject: [PATCH] Add mkdir, correct forking, & fix no-ops (#972) * Add comments * Add mkdir * continue-on-error * Redirect * Update init.yml * Remove conda-sandbox --- .github/workflows/init.yml | 42 ++++++++++++++++++++++++++++++------ .github/workflows/update.yml | 10 +++++++-- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.github/workflows/init.yml b/.github/workflows/init.yml index 4e026106..6a3f47b3 100644 --- a/.github/workflows/init.yml +++ b/.github/workflows/init.yml @@ -37,17 +37,28 @@ jobs: git config --global user.email '18747875+conda-bot@users.noreply.github.com' - name: (upstream) Remove repository from sync.yml + # no-op if the repository is not in the sync.yml file + continue-on-error: true run: sed -i '\%${{ github.event.inputs.org }}/${{ github.event.inputs.repo }}$%d' upstream/.github/sync/config.yml - name: (upstream) Commit changes - run: cd upstream && git add . && git commit --message "🤖 updated file(s)" || true + # no-op if there are no updates + continue-on-error: true + run: | + cd upstream + git add . + git commit --message "🤖 updated file(s)" - name: (upstream) Create fork - run: cd upstream && echo UPSTREAM=$(gh repo fork --clone=false --default-branch-only | awk '{print $1}') >> $GITHUB_ENV + # no-op if the repository is already forked + run: | + cd upstream + echo UPSTREAM=$(gh repo fork --clone=false --default-branch-only 2>&1 | awk '{print $1}') >> $GITHUB_ENV env: GH_TOKEN: ${{ secrets.SYNC_TOKEN }} - name: (upstream) Create PR + # no-op if no commits were made uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5 with: path: upstream @@ -66,20 +77,37 @@ jobs: ###### Auto-generated by the [`init.yml`][init.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. - name: (downstream) Copy (overwrite) update.yml - run: cp -f upstream/.github/workflows/update.yml downstream/.github/workflows/update.yml || true + # no-op if the latest file already exists in the downstream repository + continue-on-error: true + run: | + mkdir -p downstream/.github/workflows/ + cp -f upstream/.github/workflows/update.yml downstream/.github/workflows/update.yml - name: (downstream) Copy (do not overwrite) config.yml - run: cp -n upstream/templates/config.yml downstream/.github/template-files/config.yml || true + # no-op if the file already exists in the downstream repository + continue-on-error: true + run: | + mkdir -p downstream/.github/template-files/ + cp -n upstream/templates/config.yml downstream/.github/template-files/config.yml - name: (downstream) Commit changes - run: cd downstream && git add . && git commit --message "🤖 updated file(s)" || true + # no-op if there are no updates + continue-on-error: true + run: | + cd downstream + git add . + git commit --message "🤖 updated file(s)" - name: (downstream) Create fork - run: cd downstream && echo DOWNSTREAM=$(gh repo fork --clone=false --default-branch-only | awk '{print $1}') >> $GITHUB_ENV + # no-op if the repository is already forked + run: | + cd downstream + echo DOWNSTREAM=$(gh repo fork --clone=false --default-branch-only 2>&1 | awk '{print $1}') >> $GITHUB_ENV env: GH_TOKEN: ${{ secrets.SYNC_TOKEN }} - name: (downstream) Create PR + # no-op if no commits were made uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5 with: path: downstream @@ -95,4 +123,4 @@ jobs: This PR was triggered by @${{ github.triggering_actor }} via ${{ github.event_name }}. - ###### Auto-generated by the [`update.yml`][update.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. + ###### Auto-generated by the [`init.yml`][init.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 9484adf6..e0ff6ac8 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -59,16 +59,22 @@ jobs: - uses: conda/actions/template-files@976289d0cfd85139701b26ddd133abdd025a7b5f # v24.5.0 - name: Commit changes - run: git add . && git commit --message "🤖 updated file(s)" || true + # no-op if there are no updates + continue-on-error: true + run: | + git add . + git commit --message "🤖 updated file(s)" - if: github.event.comment.body != '@conda-bot render' name: Create fork - run: echo FORK=$(gh repo fork --clone=false --default-branch-only | awk '{print $1}') >> $GITHUB_ENV + # no-op if the repository is already forked + run: echo FORK=$(gh repo fork --clone=false --default-branch-only 2>&1 | awk '{print $1}') >> $GITHUB_ENV env: GH_TOKEN: ${{ secrets.SYNC_TOKEN }} - if: github.event.comment.body != '@conda-bot render' id: create + # no-op if no commits were made uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5 with: push-to-fork: ${{ env.FORK }}