update
This commit is contained in:
parent
760eb8ae72
commit
9067b1c42d
1 changed files with 24 additions and 35 deletions
59
.github/workflows/update.yml
vendored
59
.github/workflows/update.yml
vendored
|
|
@ -44,11 +44,11 @@ jobs:
|
|||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
nix flake update --accept-flake-config
|
||||
git diff
|
||||
if [[ -n $(git status -s) ]]; then
|
||||
echo "CHANGED=true" >> $GITHUB_OUTPUT
|
||||
echo "Changes detected:"
|
||||
git status -s
|
||||
git diff
|
||||
else
|
||||
echo "CHANGED=false" >> $GITHUB_OUTPUT
|
||||
echo "No changes detected."
|
||||
|
|
@ -61,31 +61,19 @@ jobs:
|
|||
git add .
|
||||
git commit -m "chore: update flake dependencies"
|
||||
git push origin ${{ env.BRANCH_NAME }}
|
||||
echo "Branch created and changes pushed."
|
||||
|
||||
- name: Create Pull Request
|
||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
||||
id: create-pr
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
title: 'Auto-update Nix flake dependencies'
|
||||
body: 'This PR updates the Nix flake dependencies.'
|
||||
branch: ${{ env.BRANCH_NAME }}
|
||||
base: main
|
||||
|
||||
- name: PR Creation Result
|
||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
echo "PR Creation Output:"
|
||||
echo "${{ toJson(steps.create-pr.outputs) }}"
|
||||
|
||||
- name: No changes detected
|
||||
if: steps.update-flake.outputs.CHANGED != 'true'
|
||||
run: |
|
||||
echo "No changes were detected in the flake.lock file. No PR created."
|
||||
gh pr create --title "Auto-update Nix flake dependencies" \
|
||||
--body "This PR updates the Nix flake dependencies." \
|
||||
--base main \
|
||||
--head ${{ env.BRANCH_NAME }}
|
||||
|
||||
- name: Create Hydra jobset
|
||||
if: steps.git-check.outputs.CHANGED == 'true' && steps.create-pr.outputs.pull-request-number
|
||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
||||
run: |
|
||||
AUTH_HEADER="Authorization: Basic $(echo -n '${{ secrets.HYDRA_USERNAME }}:${{ secrets.HYDRA_PASSWORD }}' | base64)"
|
||||
curl -X PUT -H "Content-Type: application/json" \
|
||||
|
|
@ -96,14 +84,14 @@ jobs:
|
|||
"keepnr": 3,
|
||||
"schedulingshares": 100,
|
||||
"checkinterval": 60,
|
||||
"description": "PR #${{ steps.create-pr.outputs.pull-request-number }} - Auto-update flake dependencies",
|
||||
"description": "PR #${{ github.event.pull_request.number }} - Auto-update flake dependencies",
|
||||
"flake": "github:${{ github.repository }}/${{ env.BRANCH_NAME }}",
|
||||
"type": 1
|
||||
}' \
|
||||
"${{ env.HYDRA_INSTANCE }}/jobset/${{ env.HYDRA_PROJECT }}/${{ env.HYDRA_JOBSET }}"
|
||||
|
||||
- name: Trigger Hydra build
|
||||
if: steps.git-check.outputs.CHANGED == 'true' && steps.create-pr.outputs.pull-request-number
|
||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
||||
run: |
|
||||
AUTH_HEADER="Authorization: Basic $(echo -n '${{ secrets.HYDRA_USERNAME }}:${{ secrets.HYDRA_PASSWORD }}' | base64)"
|
||||
curl -X POST -H "Content-Type: application/json" \
|
||||
|
|
@ -113,7 +101,7 @@ jobs:
|
|||
"${{ env.HYDRA_INSTANCE }}/api/push"
|
||||
|
||||
- name: Wait for Hydra build
|
||||
if: steps.git-check.outputs.CHANGED == 'true' && steps.create-pr.outputs.pull-request-number
|
||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
||||
id: wait-for-build
|
||||
run: |
|
||||
AUTH_HEADER="Authorization: Basic $(echo -n '${{ secrets.HYDRA_USERNAME }}:${{ secrets.HYDRA_PASSWORD }}' | base64)"
|
||||
|
|
@ -136,22 +124,23 @@ jobs:
|
|||
echo "BUILD_SUCCESS=false" >> $GITHUB_OUTPUT # Timeout, consider as failure
|
||||
|
||||
- name: Merge PR if build succeeds
|
||||
if: steps.git-check.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true' && steps.create-pr.outputs.pull-request-number
|
||||
run: |
|
||||
gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --merge
|
||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
pr_number=$(gh pr list --head ${{ env.BRANCH_NAME }} --json number --jq '.[0].number')
|
||||
gh pr merge $pr_number --merge
|
||||
|
||||
- name: Schedule retry if build fails
|
||||
if: steps.git-check.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS != 'true' && steps.create-pr.outputs.pull-request-number
|
||||
uses: peter-evans/create-or-update-comment@v3
|
||||
with:
|
||||
issue-number: ${{ steps.create-pr.outputs.pull-request-number }}
|
||||
body: |
|
||||
The Hydra build failed. This PR will be updated and retried in 24 hours.
|
||||
- name: Comment on PR if build fails
|
||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS != 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
pr_number=$(gh pr list --head ${{ env.BRANCH_NAME }} --json number --jq '.[0].number')
|
||||
gh pr comment $pr_number --body "The Hydra build failed. This PR will be updated and retried in 24 hours."
|
||||
|
||||
- name: Retry update after 24 hours
|
||||
if: steps.git-check.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS != 'true' && steps.create-pr.outputs.pull-request-number
|
||||
- name: Schedule retry
|
||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS != 'true'
|
||||
uses: peter-evans/repository-dispatch@v2
|
||||
with:
|
||||
event-type: retry-flake-update
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue