updates
This commit is contained in:
parent
ca07122ee6
commit
cfe4f821c9
2 changed files with 105 additions and 0 deletions
79
.github/actions/create-hydra-jobset.yml
vendored
Normal file
79
.github/actions/create-hydra-jobset.yml
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
name: 'Create Hydra Jobset'
|
||||||
|
description: 'Creates or updates a jobset on a Hydra CI server'
|
||||||
|
inputs:
|
||||||
|
hydra_instance:
|
||||||
|
description: 'URL of the Hydra instance'
|
||||||
|
required: true
|
||||||
|
hydra_project:
|
||||||
|
description: 'Name of the Hydra project'
|
||||||
|
required: true
|
||||||
|
hydra_jobset:
|
||||||
|
description: 'Name of the Hydra jobset'
|
||||||
|
required: true
|
||||||
|
hydra_username:
|
||||||
|
description: 'Username for Hydra authentication'
|
||||||
|
required: true
|
||||||
|
hydra_password:
|
||||||
|
description: 'Password for Hydra authentication'
|
||||||
|
required: true
|
||||||
|
flake_uri:
|
||||||
|
description: 'URI of the flake to build'
|
||||||
|
required: true
|
||||||
|
description:
|
||||||
|
description: 'Description of the jobset'
|
||||||
|
required: false
|
||||||
|
default: 'Auto-created jobset'
|
||||||
|
enabled:
|
||||||
|
description: 'Whether the jobset should be enabled'
|
||||||
|
required: false
|
||||||
|
default: '1'
|
||||||
|
visible:
|
||||||
|
description: 'Whether the jobset should be visible'
|
||||||
|
required: false
|
||||||
|
default: '0'
|
||||||
|
keepnr:
|
||||||
|
description: 'Number of builds to keep'
|
||||||
|
required: false
|
||||||
|
default: '3'
|
||||||
|
checkinterval:
|
||||||
|
description: 'Interval between checks in seconds'
|
||||||
|
required: false
|
||||||
|
default: '300'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Create or update Hydra jobset
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
AUTH_HEADER="Authorization: Basic $(echo -n '${{ inputs.hydra_username }}:${{ inputs.hydra_password }}' | base64)"
|
||||||
|
|
||||||
|
# Prepare the JSON payload
|
||||||
|
payload=$(cat << EOF
|
||||||
|
{
|
||||||
|
"enabled": ${{ inputs.enabled }},
|
||||||
|
"visible": ${{ inputs.visible }},
|
||||||
|
"keepnr": ${{ inputs.keepnr }},
|
||||||
|
"checkinterval": ${{ inputs.checkinterval }},
|
||||||
|
"description": "${{ inputs.description }}",
|
||||||
|
"flake": "${{ inputs.flake_uri }}",
|
||||||
|
"type": 1
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
# Send the request to create or update the jobset
|
||||||
|
response=$(curl -s -X PUT \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "$AUTH_HEADER" \
|
||||||
|
-d "$payload" \
|
||||||
|
"${{ inputs.hydra_instance }}/jobset/${{ inputs.hydra_project }}/${{ inputs.hydra_jobset }}")
|
||||||
|
|
||||||
|
# Check the response
|
||||||
|
if [[ $response == *"\"jobset\":\"${{ inputs.hydra_jobset }}\""* ]]; then
|
||||||
|
echo "Hydra jobset created or updated successfully"
|
||||||
|
else
|
||||||
|
echo "Failed to create or update Hydra jobset"
|
||||||
|
echo "Response: $response"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
26
.github/workflows/update.yml
vendored
26
.github/workflows/update.yml
vendored
|
|
@ -77,6 +77,18 @@ jobs:
|
||||||
--base main \
|
--base main \
|
||||||
--head ${{ env.BRANCH_NAME }}
|
--head ${{ env.BRANCH_NAME }}
|
||||||
|
|
||||||
|
- name: Create Hydra jobset
|
||||||
|
if: steps.update-flake.outputs.CHANGED == 'true'
|
||||||
|
uses: ./.github/actions/create-hydra-jobset
|
||||||
|
with:
|
||||||
|
hydra_instance: ${{ env.HYDRA_INSTANCE }}
|
||||||
|
hydra_project: ${{ env.HYDRA_PROJECT }}
|
||||||
|
hydra_jobset: ${{ env.HYDRA_JOBSET }}
|
||||||
|
hydra_username: ${{ secrets.HYDRA_USERNAME }}
|
||||||
|
hydra_password: ${{ secrets.HYDRA_PASSWORD }}
|
||||||
|
flake_uri: "github:${{ github.repository }}/${{ env.BRANCH_NAME }}"
|
||||||
|
description: "PR #${{ steps.create-pr.outputs.pr_number }} - Auto-update flake dependencies"
|
||||||
|
|
||||||
- name: Trigger Hydra build
|
- name: Trigger Hydra build
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
if: steps.update-flake.outputs.CHANGED == 'true'
|
||||||
uses: ./.github/actions/trigger-hydra-build
|
uses: ./.github/actions/trigger-hydra-build
|
||||||
|
|
@ -98,6 +110,13 @@ jobs:
|
||||||
hydra_username: ${{ secrets.HYDRA_USERNAME }}
|
hydra_username: ${{ secrets.HYDRA_USERNAME }}
|
||||||
hydra_password: ${{ secrets.HYDRA_PASSWORD }}
|
hydra_password: ${{ secrets.HYDRA_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Approve PR
|
||||||
|
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
gh pr review ${{ steps.create-pr.outputs.pr_number }} --approve --body "Automated approval: Hydra build succeeded"
|
||||||
|
|
||||||
- name: Merge PR if build succeeds
|
- name: Merge PR if build succeeds
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
||||||
env:
|
env:
|
||||||
|
|
@ -168,6 +187,13 @@ jobs:
|
||||||
hydra_username: ${{ secrets.HYDRA_USERNAME }}
|
hydra_username: ${{ secrets.HYDRA_USERNAME }}
|
||||||
hydra_password: ${{ secrets.HYDRA_PASSWORD }}
|
hydra_password: ${{ secrets.HYDRA_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Approve PR
|
||||||
|
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
gh pr review ${{ needs.check-existing-pr.outputs.pr_number }} --approve --body "Automated approval: Hydra build succeeded"
|
||||||
|
|
||||||
- name: Merge PR if build succeeds
|
- name: Merge PR if build succeeds
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue