Forgejo Actions #5
1 changed files with 24 additions and 45 deletions
|
|
@ -7,10 +7,11 @@ on:
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-updates:
|
prepare:
|
||||||
runs-on: nix
|
runs-on: nix
|
||||||
outputs:
|
outputs:
|
||||||
changed: ${{ steps.changes.outputs.changed }}
|
changed: ${{ steps.changes.outputs.changed }}
|
||||||
|
branch_name: ${{ steps.commit.outputs.branch_name }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
@ -30,10 +31,24 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
if git diff --quiet flake.lock; then
|
if git diff --quiet flake.lock; then
|
||||||
echo "changed=false" >> $FORGEJO_OUTPUT
|
echo "changed=false" >> $FORGEJO_OUTPUT
|
||||||
|
echo "No changes to flake.lock"
|
||||||
else
|
else
|
||||||
echo "changed=true" >> $FORGEJO_OUTPUT
|
echo "changed=true" >> $FORGEJO_OUTPUT
|
||||||
|
echo "flake.lock has been updated"
|
||||||
fi
|
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
|
- name: Extract LXC hosts
|
||||||
if: steps.changes.outputs.changed == 'true'
|
if: steps.changes.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -49,14 +64,6 @@ jobs:
|
||||||
echo "$HOSTS" > hosts.json
|
echo "$HOSTS" > hosts.json
|
||||||
echo "Discovered hosts: $HOSTS"
|
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
|
- name: Upload hosts list
|
||||||
if: steps.changes.outputs.changed == 'true'
|
if: steps.changes.outputs.changed == 'true'
|
||||||
uses: forgejo/upload-artifact@v4
|
uses: forgejo/upload-artifact@v4
|
||||||
|
|
@ -66,17 +73,14 @@ jobs:
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
build:
|
build:
|
||||||
needs: check-updates
|
needs: prepare
|
||||||
if: needs.check-updates.outputs.changed == 'true'
|
if: needs.prepare.outputs.changed == 'true'
|
||||||
runs-on: nix
|
runs-on: nix
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout update branch
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download updated flake.lock
|
|
||||||
uses: forgejo/download-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: flake-lock
|
ref: ${{ needs.prepare.outputs.branch_name }}
|
||||||
|
|
||||||
- name: Download hosts list
|
- name: Download hosts list
|
||||||
uses: forgejo/download-artifact@v4
|
uses: forgejo/download-artifact@v4
|
||||||
|
|
@ -157,25 +161,10 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
report:
|
report:
|
||||||
needs: [check-updates, build]
|
needs: [prepare, build]
|
||||||
if: always() && needs.check-updates.outputs.changed == 'true'
|
if: always() && needs.prepare.outputs.changed == 'true'
|
||||||
runs-on: nix
|
runs-on: nix
|
||||||
steps:
|
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
|
- name: Download hosts list
|
||||||
uses: forgejo/download-artifact@v4
|
uses: forgejo/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -195,16 +184,6 @@ jobs:
|
||||||
path: logs
|
path: logs
|
||||||
continue-on-error: true
|
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
|
- name: Create Pull Request
|
||||||
if: needs.build.result == 'success'
|
if: needs.build.result == 'success'
|
||||||
env:
|
env:
|
||||||
|
|
@ -219,7 +198,7 @@ jobs:
|
||||||
-d '{
|
-d '{
|
||||||
"title": "chore: weekly flake update",
|
"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)"'",
|
"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"
|
"base": "master"
|
||||||
}' \
|
}' \
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/pulls"
|
"${{ 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)"
|
FAILED_HOSTS="\n- (Unable to determine failed hosts - check workflow logs)"
|
||||||
fi
|
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 \
|
curl -X POST \
|
||||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue