Update Package Version #11
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: Update Package Version | |
on: | |
schedule: | |
- cron: '0 */6 * * *' # Every 6 hours | |
workflow_dispatch: # Allow manual trigger | |
jobs: | |
check-and-update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3 | |
- name: Build and run update in Arch container | |
run: | | |
# Build the container with caching | |
docker buildx build \ | |
--load \ | |
--cache-from type=gha \ | |
--cache-to type=gha,mode=max \ | |
-t arch-builder \ | |
-f .github/Dockerfile \ | |
.github | |
# Run the container with workspace mounted | |
docker run --rm \ | |
-v ${{ github.workspace }}:/workspace \ | |
-w /workspace \ | |
arch-builder \ | |
bash -c " | |
chown -R builder:builder /workspace && | |
su - builder -c 'cd /workspace && chmod +x update-package.sh && ./update-package.sh --ci' | |
" | |
- name: Fix file permissions | |
run: | | |
# Restore ownership to the GitHub Actions user | |
sudo chown -R $(whoami):$(whoami) ${{ github.workspace }} | |
- name: Show changes | |
run: | | |
echo "=== Git status ===" | |
git status | |
echo "=== PKGBUILD changes ===" | |
git diff sourcegraph-amp/PKGBUILD || echo "No PKGBUILD changes" | |
echo "=== .SRCINFO changes ===" | |
git diff sourcegraph-amp/.SRCINFO || echo "No .SRCINFO changes" | |
- name: Check for new commits | |
id: update | |
run: | | |
# Check if there are any new commits (indicating an update was made) | |
if [ -n "$(git log --oneline HEAD ^origin/${{ github.ref_name }} 2>/dev/null)" ]; then | |
# New commit exists, get version from latest commit | |
updated_ver=$(awk -F'=' '/^_npmver=/ {print $2}' sourcegraph-amp/PKGBUILD | cut -d' ' -f1) | |
echo "updated_version=$updated_ver" >> $GITHUB_OUTPUT | |
echo "needs_update=true" >> $GITHUB_OUTPUT | |
echo "✅ Update committed for version $updated_ver" | |
else | |
# No new commits, no update needed | |
echo "needs_update=false" >> $GITHUB_OUTPUT | |
echo "ℹ️ No update needed" | |
fi | |
- name: Create Pull Request | |
if: steps.update.outputs.needs_update == 'true' | |
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "chore(deps): update @sourcegraph/amp to ${{ steps.update.outputs.updated_version }}" | |
title: "Update @sourcegraph/amp to ${{ steps.update.outputs.updated_version }}" | |
body: | | |
🤖 **Automated package update** | |
Updates `@sourcegraph/amp` to `${{ steps.update.outputs.updated_version }}` | |
**Changes:** | |
- Updated `_npmver` to `${{ steps.update.outputs.updated_version }}` | |
- Reset `pkgrel` to `1` | |
- Updated checksums | |
- Regenerated `.SRCINFO` | |
Auto-generated by GitHub Actions 🚀 | |
branch: update/amp-${{ steps.update.outputs.updated_version }} | |
delete-branch: true |