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