Forgejo Actions #5
1 changed files with 24 additions and 45 deletions
|
|
@ -7,10 +7,11 @@ on:
|
|||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
check-updates:
|
||||
prepare:
|
||||
runs-on: nix
|
||||
outputs:
|
||||
changed: ${{ steps.changes.outputs.changed }}
|
||||
branch_name: ${{ steps.commit.outputs.branch_name }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -30,10 +31,24 @@ jobs:
|
|||
run: |
|
||||
if git diff --quiet flake.lock; then
|
||||
echo "changed=false" >> $FORGEJO_OUTPUT
|
||||
echo "No changes to flake.lock"
|
||||
else
|
||||
echo "changed=true" >> $FORGEJO_OUTPUT
|
||||
echo "flake.lock has been updated"
|
||||
fi
|
||||
|
||||
- name: Create branch and commit
|
||||
id: commit
|
||||
if: steps.changes.outputs.changed == 'true'
|
||||
run: |
|
||||
BRANCH_NAME="auto-update/$(date +%Y-%m-%d)"
|
||||
git checkout -b "$BRANCH_NAME"
|
||||
git add flake.lock
|
||||
git commit -m "chore: update flake inputs $(date +%Y-%m-%d)"
|
||||
git push origin "$BRANCH_NAME"
|
||||
echo "branch_name=$BRANCH_NAME" >> $FORGEJO_OUTPUT
|
||||
echo "Created and pushed branch: $BRANCH_NAME"
|
||||
|
||||
- name: Extract LXC hosts
|
||||
if: steps.changes.outputs.changed == 'true'
|
||||
run: |
|
||||
|
|
@ -49,14 +64,6 @@ jobs:
|
|||
echo "$HOSTS" > hosts.json
|
||||
echo "Discovered hosts: $HOSTS"
|
||||
|
||||
- name: Upload flake.lock
|
||||
if: steps.changes.outputs.changed == 'true'
|
||||
uses: forgejo/upload-artifact@v4
|
||||
with:
|
||||
name: flake-lock
|
||||
path: flake.lock
|
||||
retention-days: 1
|
||||
|
||||
- name: Upload hosts list
|
||||
if: steps.changes.outputs.changed == 'true'
|
||||
uses: forgejo/upload-artifact@v4
|
||||
|
|
@ -66,17 +73,14 @@ jobs:
|
|||
retention-days: 1
|
||||
|
||||
build:
|
||||
needs: check-updates
|
||||
if: needs.check-updates.outputs.changed == 'true'
|
||||
needs: prepare
|
||||
if: needs.prepare.outputs.changed == 'true'
|
||||
runs-on: nix
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
- name: Checkout update branch
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download updated flake.lock
|
||||
uses: forgejo/download-artifact@v4
|
||||
with:
|
||||
name: flake-lock
|
||||
ref: ${{ needs.prepare.outputs.branch_name }}
|
||||
|
||||
- name: Download hosts list
|
||||
uses: forgejo/download-artifact@v4
|
||||
|
|
@ -157,25 +161,10 @@ jobs:
|
|||
fi
|
||||
|
||||
report:
|
||||
needs: [check-updates, build]
|
||||
if: always() && needs.check-updates.outputs.changed == 'true'
|
||||
needs: [prepare, build]
|
||||
if: always() && needs.prepare.outputs.changed == 'true'
|
||||
runs-on: nix
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config user.name "Flake Update Bot"
|
||||
git config user.email "bot@noreply.local"
|
||||
|
||||
- name: Download updated flake.lock
|
||||
uses: forgejo/download-artifact@v4
|
||||
with:
|
||||
name: flake-lock
|
||||
|
||||
- name: Download hosts list
|
||||
uses: forgejo/download-artifact@v4
|
||||
with:
|
||||
|
|
@ -195,16 +184,6 @@ jobs:
|
|||
path: logs
|
||||
continue-on-error: true
|
||||
|
||||
- name: Create branch and commit
|
||||
id: branch
|
||||
run: |
|
||||
BRANCH_NAME="auto-update/$(date +%Y-%m-%d)"
|
||||
git checkout -b "$BRANCH_NAME"
|
||||
git add flake.lock
|
||||
git commit -m "chore: update flake inputs $(date +%Y-%m-%d)"
|
||||
git push origin "$BRANCH_NAME"
|
||||
echo "branch_name=$BRANCH_NAME" >> $FORGEJO_OUTPUT
|
||||
|
||||
- name: Create Pull Request
|
||||
if: needs.build.result == 'success'
|
||||
env:
|
||||
|
|
@ -219,7 +198,7 @@ jobs:
|
|||
-d '{
|
||||
"title": "chore: weekly flake update",
|
||||
"body": "Automated flake update from CI.\n\nThis PR updates all flake inputs and has been verified to build successfully.\n\n**Hosts built:**\n'"$(echo "$HOST_LIST" | sed 's/$/\\n/g' | tr -d '\n')"'\n\nGenerated on: '"$(date -Iseconds)"'",
|
||||
"head": "'"${{ steps.branch.outputs.branch_name }}"'",
|
||||
"head": "'"${{ needs.prepare.outputs.branch_name }}"'",
|
||||
"base": "master"
|
||||
}' \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/pulls"
|
||||
|
|
@ -249,7 +228,7 @@ jobs:
|
|||
FAILED_HOSTS="\n- (Unable to determine failed hosts - check workflow logs)"
|
||||
fi
|
||||
|
||||
ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ steps.branch.outputs.branch_name }}\`\n**Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)"
|
||||
ISSUE_BODY="Weekly flake update failed to build some hosts.\n\n**Branch:** \`${{ needs.prepare.outputs.branch_name }}\`\n**Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\n**Failed hosts:**$FAILED_HOSTS\n$FAILURE_DETAILS\n\nGenerated on: $(date -Iseconds)"
|
||||
|
||||
curl -X POST \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue