Repository navigation
81 lines (69 loc) · 2.8 KB
/
Copy pathupdate_upstream.yml
File metadata and controls
81 lines (69 loc) · 2.8 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
name: update tag
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * *'
jobs:
update:
name: Check and update UPSTREAM_TAG
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Get latest upstream tag
id: upstream
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
latest=$(gh release view --repo astral-sh/python-build-standalone --json tagName --jq '.tagName')
echo "tag=$latest" >> "$GITHUB_OUTPUT"
- name: Get current tag from UPSTREAM_TAG file
id: current
run: |
current=$(cat UPSTREAM_TAG)
echo "tag=$current" >> "$GITHUB_OUTPUT"
- name: Update UPSTREAM_TAG file if outdated
id: changes
run: |
latest="${{ steps.upstream.outputs.tag }}"
current="${{ steps.current.outputs.tag }}"
if [ "$latest" = "$current" ]; then
echo "Already up-to-date: $current"
echo "has_changes=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Updating UPSTREAM_TAG from $current to $latest"
echo "$latest" > UPSTREAM_TAG
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "latest=$latest" >> "$GITHUB_OUTPUT"
echo "current=$current" >> "$GITHUB_OUTPUT"
- name: Configure Git
if: steps.changes.outputs.has_changes == 'true'
run: |
git config user.name "Garden Linux Bot"
git config user.email "gardenlinux[bot]@users.noreply.github.com"
- name: Create branch and pull request
if: steps.changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
latest="${{ steps.changes.outputs.latest }}"
current="${{ steps.changes.outputs.current }}"
branch="update-upstream-tag-${latest}"
existing=$(gh pr list --base main --head "${branch}" --json number --jq '.[0].number' || echo "")
if [ -n "${existing}" ]; then
echo "PR #${existing} already exists for branch ${branch}, skipping."
exit 0
fi
git checkout -b "${branch}"
git add UPSTREAM_TAG
git commit -s -m "chore: update UPSTREAM_TAG from ${current} to ${latest}"
git push origin "${branch}" -f
gh pr create \
--base main \
--head "${branch}" \
--title "chore: update UPSTREAM_TAG from ${current} to ${latest}" \
--body "Automated update of \`UPSTREAM_TAG\` from \`${current}\` to \`${latest}\` from [astral-sh/python-build-standalone](https://github.com/astral-sh/python-build-standalone/releases/tag/${latest})."