Skip to content

Commit 004e48d

Browse files
authored
Adding some guardrails
1 parent b292bc9 commit 004e48d

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
name: Watch upstream dnscrypt-proxy releases (update testing)
1+
name: Watch upstream dnscrypt-proxy releases (auto-update testing)
22

33
on:
44
schedule:
5-
- cron: "0 9 * * *" # once per day at 09:00 UTC
5+
- cron: "0 9 * * *" # daily at 09:00 UTC
66
workflow_dispatch:
77

88
permissions:
99
contents: write
10-
pull-requests: write
1110

1211
jobs:
1312
bump:
13+
# Guard rail: scheduled runs will already use the default branch workflow file,
14+
# but this prevents accidental manual runs from non-default branches doing unexpected things.
15+
if: github.ref_name == 'master'
1416
runs-on: ubuntu-latest
1517

1618
steps:
1719
- name: Checkout testing branch
1820
uses: actions/checkout@v4
1921
with:
2022
ref: testing
23+
fetch-depth: 0
2124

2225
- name: Get latest upstream release version
2326
id: upstream
2427
shell: bash
2528
run: |
2629
LATEST="$(curl -fsSL https://api.github.com/repos/DNSCrypt/dnscrypt-proxy/releases/latest \
2730
| python -c "import sys,json; print(json.load(sys.stdin)['tag_name'].lstrip('v'))")"
28-
29-
echo "Latest upstream version: $LATEST"
3031
echo "latest=$LATEST" >> "$GITHUB_OUTPUT"
32+
echo "Latest upstream: $LATEST"
3133
32-
- name: Update DNSCRYPT_PROXY_VERSION if needed
34+
- name: Compare & update DNSCRYPT_PROXY_VERSION
3335
id: update
3436
shell: bash
3537
run: |
3638
CURRENT="$(cat DNSCRYPT_PROXY_VERSION 2>/dev/null || true)"
3739
LATEST="${{ steps.upstream.outputs.latest }}"
3840
39-
echo "Current version in repo: $CURRENT"
40-
echo "Latest upstream version: $LATEST"
41+
echo "Current in testing: $CURRENT"
42+
echo "Latest upstream: $LATEST"
43+
44+
if [ -z "$LATEST" ]; then
45+
echo "Upstream version is empty. Failing for safety."
46+
exit 1
47+
fi
4148
42-
# Nothing to do if empty or unchanged
43-
if [ -z "$LATEST" ] || [ "$CURRENT" = "$LATEST" ]; then
49+
if [ "$CURRENT" = "$LATEST" ]; then
4450
echo "No update needed."
4551
echo "changed=false" >> "$GITHUB_OUTPUT"
4652
exit 0
4753
fi
4854
49-
echo "Updating DNSCRYPT_PROXY_VERSION to $LATEST"
5055
echo "$LATEST" > DNSCRYPT_PROXY_VERSION
5156
echo "changed=true" >> "$GITHUB_OUTPUT"
5257
53-
- name: Create PR into testing
58+
- name: Commit and push to testing
5459
if: steps.update.outputs.changed == 'true'
55-
uses: peter-evans/create-pull-request@v6
56-
with:
57-
branch: chore/bump-dnscrypt-proxy
58-
base: testing
59-
title: "chore: bump dnscrypt-proxy to ${{ steps.upstream.outputs.latest }}"
60-
commit-message: "chore: bump dnscrypt-proxy to ${{ steps.upstream.outputs.latest }}"
61-
body: |
62-
This PR automatically updates DNSCRYPT_PROXY_VERSION
63-
to the latest upstream dnscrypt-proxy release: ${{ steps.upstream.outputs.latest }}
60+
shell: bash
61+
run: |
62+
git config user.name "github-actions[bot]"
63+
git config user.email "github-actions[bot]@users.noreply.github.com"
6464
65-
When merged, the testing branch will rebuild the Docker image
66-
and publish new :testing and :testing-<version> tags.
67-
labels: dependencies
65+
git add DNSCRYPT_PROXY_VERSION
66+
git commit -m "chore: bump dnscrypt-proxy to ${{ steps.upstream.outputs.latest }}"
67+
git push origin HEAD:testing

0 commit comments

Comments
 (0)