Skip to content

Commit 5c88c45

Browse files
authored
Try manually setting status (#36)
new tactic
1 parent 4dbd85d commit 5c88c45

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: v0.0.41-18-gec81ebb
2+
_commit: v0.0.41-21-g8ca6c25
33
_src_path: gh:LabAutomationAndScreening/copier-base-template.git
44
description: Copier template for creating Python libraries and executables
55
python_ci_versions:

.github/actions/update-devcontainer-hash/action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ inputs:
88
permissions:
99
contents: write
1010

11+
outputs:
12+
new-sha:
13+
description: 'The SHA of the branch tip after update'
14+
value: ${{ steps.commit-and-push.outputs.new-sha }}
15+
commit-created:
16+
description: 'Whether a new commit was created and pushed'
17+
value: ${{ steps.commit-and-push.outputs.commit-created }}
1118

1219
runs:
1320
using: composite
@@ -38,12 +45,16 @@ runs:
3845
shell: bash
3946

4047
- name: Commit & push changes
48+
id: commit-and-push
4149
run: |
4250
if ! git diff --quiet; then
4351
git add .
4452
git commit -m "chore: update devcontainer hash [dependabot skip]"
4553
git push origin HEAD:${{ inputs.branch }}
54+
echo "commit-created=true" >> $GITHUB_OUTPUT
55+
echo "new-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
4656
else
4757
echo "No changes to commit"
58+
echo "commit-created=false" >> $GITHUB_OUTPUT
4859
fi
4960
shell: bash

.github/workflows/ci.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ env:
1313
permissions:
1414
id-token: write
1515
contents: write # needed for mutex
16+
statuses: write # needed for updating status on Dependabot PRs
1617

1718
jobs:
1819
get-values:
1920
runs-on: ubuntu-24.04
21+
outputs:
22+
new-dependabot-sha: ${{ steps.update-hash.outputs.new-sha }}
23+
dependabot-commit-created: ${{ steps.update-hash.outputs.commit-created }}
2024
steps:
2125
- name: Checkout code
2226
uses: actions/checkout@v4.2.2
2327

2428
- name: Update Devcontainer Hash
2529
if: ${{ github.actor == 'dependabot[bot]' }}
30+
id: update-hash
2631
uses: ./.github/actions/update-devcontainer-hash
2732
with:
2833
branch: ${{ github.ref_name }}
@@ -170,10 +175,21 @@ jobs:
170175

171176
required-check:
172177
runs-on: ubuntu-24.04
173-
needs: [ lint-matrix ]
178+
needs: [ lint-matrix, get-values ]
174179
if: always()
175180
steps:
176181
- name: fail if prior job failure
177182
if: needs.lint-matrix.result != 'success'
178183
run: |
179184
exit 1
185+
- name: Make updated dependabot hash commit as succeeded
186+
if: needs.get-values.outputs.dependabot-commit-created == 'true'
187+
run: |
188+
gh api \
189+
-X POST \
190+
-H "Accept: application/vnd.github.v3+json" \
191+
"/repos/${{ github.repository }}/statuses/${{ needs.get-values.outputs.new-dependabot-sha }}" \
192+
-f state=success \
193+
-f context="required-check" \
194+
-f description="Initial CI run passed" \
195+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

template/.github/actions/update-devcontainer-hash/action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ inputs:
88
permissions:
99
contents: write
1010

11+
outputs:
12+
new-sha:
13+
description: 'The SHA of the branch tip after update'
14+
value: ${{ steps.commit-and-push.outputs.new-sha }}
15+
commit-created:
16+
description: 'Whether a new commit was created and pushed'
17+
value: ${{ steps.commit-and-push.outputs.commit-created }}
1118

1219
runs:
1320
using: composite
@@ -38,12 +45,16 @@ runs:
3845
shell: bash
3946

4047
- name: Commit & push changes
48+
id: commit-and-push
4149
run: |
4250
if ! git diff --quiet; then
4351
git add .
4452
git commit -m "chore: update devcontainer hash [dependabot skip]"
4553
git push origin HEAD:${{ inputs.branch }}
54+
echo "commit-created=true" >> $GITHUB_OUTPUT
55+
echo "new-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
4656
else
4757
echo "No changes to commit"
58+
echo "commit-created=false" >> $GITHUB_OUTPUT
4859
fi
4960
shell: bash

0 commit comments

Comments
 (0)