-
Notifications
You must be signed in to change notification settings - Fork 8
102 lines (85 loc) · 3.18 KB
/
Copy pathupdate.yml
File metadata and controls
102 lines (85 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: 🤖 Auto update ports
on:
workflow_dispatch:
schedule:
- cron: "15 5 * * 1"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update_packages:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 10
ssh-key: ${{ secrets.UPDATE_BOT_SSH_KEY }}
persist-credentials: true
- name: Setup vcpkg
uses: ./.github/actions/setup-vcpkg
- name: Update ports
run: |
python ./scripts/update-ports.py 2>&1 | tee /tmp/update-output.txt
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Format vcpkg.json
run: |
vcpkg format-manifest --all $(find . -name "vcpkg.json")
git config --global user.email "updatebot@open-vcpkg"
git config --global user.name "Update Bot"
git add ports
git commit -m "Autoupdating ports" || echo "No port changes to commit"
- name: Update versions
run: |
for dir in ports/* ; do
vcpkg x-add-version ${dir##ports/} --overlay-ports=./ports \
--x-builtin-registry-versions-dir=./versions/ \
--x-builtin-ports-root=./ports
done
git add versions
git commit --am --no-edit || echo "No version changes to commit"
- name: Create or Update Pull Request
run: |
# Fetch existing remote branch
if git ls-remote --exit-code --heads origin auto-update >/dev/null 2>&1; then
git fetch origin auto-update:"refs/remotes/origin/auto-update"
fi
# Check if there are commits ahead of origin/main
if git diff --quiet origin/main..HEAD; then
echo "No changes vs origin/main."
# If a stale PR branch exists with no diff, nothing to do.
exit 0
fi
# Build summary from update output
SUMMARY=$(awk '/^={10,}/{found=1; next} found' /tmp/update-output.txt)
git checkout -B auto-update
git push --force origin auto-update
# Check if a PR already exists for this branch
EXISTING_PR=$(gh pr list --head auto-update --state open --json number --jq '.[0].number // empty')
if [ -n "$EXISTING_PR" ]; then
echo "PR #$EXISTING_PR already exists, updating title and body..."
gh pr edit "$EXISTING_PR" \
--title "🚀 Auto-update ports $(date +%Y-%m-%d)" \
--body "$SUMMARY"
else
gh pr create \
--title "🚀 Auto-update ports $(date +%Y-%m-%d)" \
--body "$SUMMARY" \
--base main \
--head auto-update
fi
env:
GH_TOKEN: ${{ secrets.PAT }}
- name: Enable Auto-Merge
continue-on-error: true
run: |
PR_NUMBER=$(gh pr list --head auto-update --state open --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
gh pr merge --merge --auto "$PR_NUMBER"
fi
env:
GH_TOKEN: ${{ secrets.PAT }}