This repository was archived by the owner on Aug 23, 2026. It is now read-only.
Repository navigation
Sync libvhdi upstream #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check for libvhdi updates | |
| on: | |
| schedule: | |
| - cron: '15 5 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: "Run update detection and validation without creating a pull request" | |
| required: false | |
| default: false | |
| type: boolean | |
| jobs: | |
| check-update: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v27 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-unstable | |
| - name: Setup Cachix (optional) | |
| if: env.CACHIX_CACHE_NAME != '' && env.CACHIX_AUTH_TOKEN != '' | |
| env: | |
| CACHIX_CACHE_NAME: ${{ vars.CACHIX_CACHE_NAME }} | |
| CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
| uses: cachix/cachix-action@v15 | |
| with: | |
| name: ${{ env.CACHIX_CACHE_NAME }} | |
| authToken: ${{ env.CACHIX_AUTH_TOKEN }} | |
| continue-on-error: true | |
| - name: Run updater script | |
| run: | | |
| chmod +x ./update.sh | |
| ./update.sh | |
| - name: Detect changes | |
| id: detect | |
| run: | | |
| if git diff --quiet -- default.nix; then | |
| echo "update_available=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| new_version=$(sed -nE 's/^[[:space:]]*version[[:space:]]*\?[[:space:]]*"([0-9]{8})".*/\1/p' default.nix | head -1) | |
| echo "update_available=true" >> "$GITHUB_OUTPUT" | |
| echo "new_version=$new_version" >> "$GITHUB_OUTPUT" | |
| echo "branch_name=update/libvhdi-$new_version" >> "$GITHUB_OUTPUT" | |
| - name: Validate updated package | |
| if: steps.detect.outputs.update_available == 'true' | |
| run: nix build .#libvhdi -L | |
| - name: Report dry run result | |
| if: steps.detect.outputs.update_available == 'true' && github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true' | |
| run: | | |
| echo "Dry run detected an available libvhdi update to ${{ | |
| steps.detect.outputs.new_version | |
| }}." | |
| echo "Validation succeeded and no pull request was created." | |
| - name: Create GitHub App token | |
| id: app_token | |
| if: steps.detect.outputs.update_available == 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.dry_run != 'true') | |
| continue-on-error: true | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ vars.UPDATE_GITHUB_APP_ID }} | |
| private-key: ${{ secrets.UPDATE_GITHUB_APP_PRIVATE_KEY }} | |
| permission-contents: write | |
| permission-pull-requests: write | |
| - name: Create Pull Request | |
| id: create_pr | |
| if: steps.detect.outputs.update_available == 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.dry_run != 'true') && steps.app_token.outcome == 'success' | |
| continue-on-error: true | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ steps.app_token.outputs.token }} | |
| commit-message: "libvhdi: update to ${{ steps.detect.outputs.new_version }}" | |
| title: "libvhdi: update to ${{ steps.detect.outputs.new_version }}" | |
| body: | | |
| Automated update to libvhdi ${{ steps.detect.outputs.new_version }}. | |
| Changes include: | |
| - `version` | |
| - `srcHash` | |
| Validation: | |
| - `nix build .#libvhdi -L` | |
| - built outputs will be pushed to Cachix when `CACHIX_CACHE_NAME` and `CACHIX_AUTH_TOKEN` are configured | |
| branch: ${{ steps.detect.outputs.branch_name }} | |
| add-paths: | | |
| default.nix | |
| delete-branch: true | |
| - name: Report PR result | |
| if: steps.detect.outputs.update_available == 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.dry_run != 'true') | |
| run: | | |
| branch_name="${{ steps.detect.outputs.branch_name }}" | |
| compare_url="https://github.com/${{ github.repository }}/compare/main...${branch_name}?expand=1" | |
| pull_url="https://github.com/${{ github.repository }}/pull/new/${branch_name}" | |
| if [ "${{ steps.app_token.outcome }}" != "success" ]; then | |
| echo "GitHub App token creation failed." >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "Configure the GitHub App credentials before rerunning this workflow:" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Variable: \`UPDATE_GITHUB_APP_ID\`" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Secret: \`UPDATE_GITHUB_APP_PRIVATE_KEY\`" >> "$GITHUB_STEP_SUMMARY" | |
| echo "::warning::GitHub App token creation failed. Verify UPDATE_GITHUB_APP_ID, UPDATE_GITHUB_APP_PRIVATE_KEY, and the app installation." | |
| elif [ "${{ steps.create_pr.outcome }}" = "success" ]; then | |
| echo "Automated pull request step succeeded." >> "$GITHUB_STEP_SUMMARY" | |
| if [ -n "${{ steps.create_pr.outputs.pull-request-url }}" ]; then | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "Pull request: ${{ steps.create_pr.outputs.pull-request-url }}" >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| else | |
| echo "Automated pull request creation is not permitted in this repository." >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "The update branch was pushed successfully and is ready for manual review." >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Branch: \`${branch_name}\`" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Open PR: ${pull_url}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Compare diff: ${compare_url}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "::warning::Automatic pull request creation was blocked. Open a PR manually from ${pull_url}" | |
| fi |