Skip to content

Commit 876bf2b

Browse files
committed
Switch pre-commit update workflow to use two tokens
In this merge, we go back to the simplified workflow that does not use conda to install `gh` and instead use the latest `gh` from github-actions. This requires using a personal access token (PAT) to set reviewers and labels, so one has been added to the repo. We still use the github-actions bot to open the PR so it doesn't get opened as @xylar (and @xylar can still review).
1 parent 702018e commit 876bf2b

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

.github/workflows/pre_commit_update_workflow.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,16 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@v4
2525

26-
- name: Set up Conda Environment
27-
uses: mamba-org/setup-micromamba@v2
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
2828
with:
29-
environment-name: pre_commit_dev
30-
init-shell: bash
31-
condarc: |
32-
channel_priority: strict
33-
channels:
34-
- conda-forge
35-
create-args: >-
36-
python=${{ env.PYTHON_VERSION }}
29+
python-version: ${{ env.PYTHON_VERSION }}
3730

38-
- name: Install pre-commit and gh
39-
run: |
40-
eval "$(micromamba shell hook --shell bash)"
41-
micromamba activate pre_commit_dev
42-
# permissions issue with gh 2.76.0
43-
conda install -y pre-commit "gh !=2.76.0"
44-
gh --version
31+
- name: Install pre-commit
32+
run: pip install pre-commit
4533

4634
- name: Apply and commit updates
4735
run: |
48-
eval "$(micromamba shell hook --shell bash)"
49-
micromamba activate pre_commit_dev
5036
git clone https://github.com/MPAS-Dev/pyremap.git update-pre-commit-deps
5137
cd update-pre-commit-deps
5238
# Configure git using GitHub Actions credentials.
@@ -60,7 +46,7 @@ jobs:
6046
git commit -m "Update pre-commit dependencies" \
6147
|| ( echo "UP_TO_DATE=true" >> "$GITHUB_ENV")
6248
63-
- name: Push Changes
49+
- name: Push Changes with github-actions bot
6450
if: ${{ env.UP_TO_DATE == 'false' }}
6551
uses: ad-m/github-push-action@master
6652
with:
@@ -71,16 +57,30 @@ jobs:
7157
env:
7258
GH_TOKEN: ${{ github.token }}
7359

74-
- name: Make PR and add reviewers and labels
60+
- name: Create PR with github-actions bot
7561
if: ${{ env.UP_TO_DATE == 'false' }}
7662
run: |
7763
cd update-pre-commit-deps
7864
gh pr create \
79-
--title "Update pre-commit and its dependencies" \
80-
--body "This PR was auto-generated to update pre-commit and its dependencies." \
81-
--head update-pre-commit-deps \
82-
--reviewer ${{ env.REVIEWERS }} \
83-
--label ci
65+
--title "Update pre-commit and its dependencies" \
66+
--body "This PR was auto-generated to update pre-commit and its dependencies." \
67+
--head update-pre-commit-deps
8468
env:
8569
GH_TOKEN: ${{ github.token }}
8670

71+
- name: Add reviewers and labels with PAT
72+
if: ${{ env.UP_TO_DATE == 'false' }}
73+
run: |
74+
cd update-pre-commit-deps
75+
76+
gh pr edit --add-label ci
77+
78+
IFS=',' read -ra reviewers <<< "${REVIEWERS}"
79+
for reviewer in "${reviewers[@]}"; do
80+
echo "Adding reviewer: $reviewer"
81+
gh pr edit --add-reviewer "$reviewer"
82+
done
83+
84+
env:
85+
REVIEWERS: ${{ env.REVIEWERS }}
86+
GH_TOKEN: ${{ secrets.GH_CLI_TOKEN }}

0 commit comments

Comments
 (0)