Skip to content

Commit 62e7243

Browse files
test github action
chore(deps): update peter-evans/create-pull-request action to v7 chore(deps): update dependency node to v22 chore(deps): pin dependencies
1 parent 18bbeb9 commit 62e7243

File tree

3 files changed

+164
-0
lines changed

3 files changed

+164
-0
lines changed

.github/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM archlinux:latest
2+
3+
# Install all required packages in one layer
4+
RUN pacman -Syu --noconfirm \
5+
base-devel \
6+
git \
7+
nodejs \
8+
npm \
9+
pacman-contrib \
10+
sudo \
11+
&& pacman -Scc --noconfirm
12+
13+
# Create builder user with sudo privileges
14+
RUN useradd -m builder && \
15+
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
16+
17+
# Set git configuration for the builder user
18+
USER builder
19+
RUN git config --global user.email 'action@github.com' && \
20+
git config --global user.name 'GitHub Action'
21+
22+
# Switch back to root for workflow execution
23+
USER root
24+
25+
WORKDIR /workspace

.github/workflows/auto-update.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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

.github/workflows/publish-aur.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish to AUR
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- github-action-test
8+
paths:
9+
- 'PKGBUILD'
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Find updated package
21+
run: |
22+
#!/usr/bin/env bash
23+
set -euxo pipefail
24+
25+
echo "pkgbuild=$(git diff --name-only HEAD HEAD~1 "*/.SRCINFO" | head -1 | xargs dirname)" >> $GITHUB_ENV
26+
27+
- name: Deploy to AUR
28+
uses: KSXGitHub/github-actions-deploy-aur@2ac5a4c1d7035885d46b10e3193393be8460b6f1 # v4.1.1
29+
if: ${{ env.pkgbuild != '' && github.ref == 'refs/heads/master' }}
30+
with:
31+
pkgname: sourcegraph-amp
32+
pkgbuild: ./PKGBUILD
33+
commit_username: ${{ secrets.AUR_USERNAME }}
34+
commit_email: ${{ secrets.AUR_EMAIL }}
35+
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
36+
37+
- name: Test Mode (Skip AUR Deploy)
38+
if: ${{ env.pkgbuild != '' && github.ref == 'refs/heads/github-action-test' }}
39+
run: |
40+
echo "🧪 TEST MODE: Would deploy to AUR with:"
41+
echo "Package: sourcegraph-amp"
42+
echo "PKGBUILD: ./PKGBUILD"
43+
echo "Files that would be deployed:"
44+
ls -la PKGBUILD .SRCINFO
45+
echo ""
46+
echo "PKGBUILD content:"
47+
cat PKGBUILD

0 commit comments

Comments
 (0)