|
| 1 | +name: Update AUR Package |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 */6 * * *' # Every 6 hours |
| 6 | + workflow_dispatch: # Allow manual trigger |
| 7 | + |
| 8 | +jobs: |
| 9 | + check-and-update: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 14 | + with: |
| 15 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 16 | + fetch-depth: 0 |
| 17 | + |
| 18 | + - name: Set up Docker Buildx |
| 19 | + uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3 |
| 20 | + |
| 21 | + - name: Build and run update in Arch container |
| 22 | + run: | |
| 23 | + # Build the container with caching |
| 24 | + docker buildx build \ |
| 25 | + --load \ |
| 26 | + --cache-from type=gha \ |
| 27 | + --cache-to type=gha,mode=max \ |
| 28 | + -t arch-builder \ |
| 29 | + -f .github/Dockerfile \ |
| 30 | + .github |
| 31 | + |
| 32 | + # Run the container with workspace mounted |
| 33 | + docker run --rm \ |
| 34 | + -v ${{ github.workspace }}:/workspace \ |
| 35 | + -w /workspace \ |
| 36 | + arch-builder \ |
| 37 | + bash -c " |
| 38 | + chown -R builder:builder /workspace && |
| 39 | + su - builder -c 'cd /workspace && chmod +x update-package.sh && ./update-package.sh --ci' |
| 40 | + " |
| 41 | +
|
| 42 | + - name: Fix file permissions |
| 43 | + run: | |
| 44 | + # Restore ownership to the GitHub Actions user |
| 45 | + sudo chown -R $(whoami):$(whoami) ${{ github.workspace }} |
| 46 | +
|
| 47 | + - name: Show changes |
| 48 | + run: | |
| 49 | + echo "=== Git status ===" |
| 50 | + git status |
| 51 | + echo "=== PKGBUILD changes ===" |
| 52 | + git diff PKGBUILD || echo "No PKGBUILD changes" |
| 53 | + echo "=== .SRCINFO changes ===" |
| 54 | + git diff .SRCINFO || echo "No .SRCINFO changes" |
| 55 | +
|
| 56 | + - name: Check for new commits |
| 57 | + id: update |
| 58 | + run: | |
| 59 | + # Check if there are any new commits (indicating an update was made) |
| 60 | + if [ -n "$(git log --oneline HEAD ^origin/${{ github.ref_name }} 2>/dev/null)" ]; then |
| 61 | + # New commit exists, get version from latest commit |
| 62 | + updated_ver=$(awk -F'=' '/^_npmver=/ {print $2}' PKGBUILD | cut -d' ' -f1) |
| 63 | + echo "updated_version=$updated_ver" >> $GITHUB_OUTPUT |
| 64 | + echo "needs_update=true" >> $GITHUB_OUTPUT |
| 65 | + echo "✅ Update committed for version $updated_ver" |
| 66 | + else |
| 67 | + # No new commits, no update needed |
| 68 | + echo "needs_update=false" >> $GITHUB_OUTPUT |
| 69 | + echo "ℹ️ No update needed" |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Create Pull Request |
| 73 | + if: steps.update.outputs.needs_update == 'true' |
| 74 | + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7 |
| 75 | + with: |
| 76 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + commit-message: "chore(deps): update @sourcegraph/amp to ${{ steps.update.outputs.updated_version }}" |
| 78 | + title: "Update @sourcegraph/amp to ${{ steps.update.outputs.updated_version }}" |
| 79 | + body: | |
| 80 | + 🤖 **Automated package update** |
| 81 | + |
| 82 | + Updates `@sourcegraph/amp` to `${{ steps.update.outputs.updated_version }}` |
| 83 | + |
| 84 | + **Changes:** |
| 85 | + - Updated `_npmver` to `${{ steps.update.outputs.updated_version }}` |
| 86 | + - Reset `pkgrel` to `1` |
| 87 | + - Updated checksums |
| 88 | + - Regenerated `.SRCINFO` |
| 89 | + |
| 90 | + Auto-generated by GitHub Actions 🚀 |
| 91 | + branch: update/amp-${{ steps.update.outputs.updated_version }} |
| 92 | + delete-branch: true |
0 commit comments