forked from pavlovic-ivan/ephemeral-github-runner-image
-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (40 loc) · 1.57 KB
/
update-versions.yaml
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
name: Check For Latest Versions
on:
schedule:
- cron: '0 0 * * *'
env:
NEW_BRANCH: bump-versions-${{ github.run_id }}
jobs:
check-version:
runs-on: ubuntu-20.04
steps:
- name: Checkout Packer Project
uses: actions/checkout@v3
- name: Compare versions
id: compare-versions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI_COMMIT_MESSAGE: Continuous Integration Commit Artifacts
CI_COMMIT_AUTHOR: Continuous Integration
run: |
current_version=$(cat versions.json | jq -r '.runner')
latest_version=$(gh api /repos/actions/runner/releases/latest | jq -r .tag_name)
if [ "$current_version" = "$latest_version" ]; then
matching=true;
else
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "[email protected]"
git checkout -b $NEW_BRANCH
cat versions.json | jq --arg v "$latest_version" '.runner = ($v)' > tmp.json
cat tmp.json > versions.json
rm tmp.json
git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}"
git push origin $NEW_BRANCH
matching=false
fi
echo "::set-output name=matching::$matching"
- name: Create PR
if: ${{ steps.compare-versions.outputs.matching == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr create --title "[bot] Bump versions" --body "Versions bumped" -B main -H $NEW_BRANCH