Skip to content

Commit

Permalink
Add mkdir, correct forking, & fix no-ops (#972)
Browse files Browse the repository at this point in the history
* Add comments

* Add mkdir

* continue-on-error

* Redirect

* Update init.yml

* Remove conda-sandbox
  • Loading branch information
kenodegard authored Jul 31, 2024
1 parent 71cbd98 commit 97d5819
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
42 changes: 35 additions & 7 deletions .github/workflows/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,28 @@ jobs:
git config --global user.email '[email protected]'
- 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
Expand All @@ -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
Expand All @@ -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 }}.
10 changes: 8 additions & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 97d5819

Please sign in to comment.