-
Notifications
You must be signed in to change notification settings - Fork 80
63 lines (53 loc) · 2.17 KB
/
devbox-update.yml
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
name: Weekly Devbox Update
on:
schedule:
- cron: '0 0 * * 0' # This cron expression runs the action at 00:00 UTC every Sunday
workflow_dispatch:
jobs:
update-devbox:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install devbox
uses: jetify-com/[email protected]
with:
enable-cache: 'true'
- name: Update Devbox
run: |
devbox update
- name: Check for Changes
id: check_changes
run: |
if git diff --quiet; then
echo "No changes to commit."
echo "CHANGES=false" >> $GITHUB_OUTPUT
else
echo "Changes detected."
echo "CHANGES=true" >> $GITHUB_OUTPUT
fi
- name: Generate Branch Name
id: generate_branch
if: steps.check_changes.outputs.CHANGES == 'true'
run: |
RANDOM_NUM=$((RANDOM % 10000)) # Generate a random number between 0 and 9999
BRANCH_NAME="devbox-update-$(date +'%Y-%m-%d')-$RANDOM_NUM"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT # Export branch name
- name: Commit and Push Changes
if: steps.check_changes.outputs.CHANGES == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "AKOBot"
git checkout -b ${{ steps.generate_branch.outputs.BRANCH_NAME }} # New branch
git add .
git commit -m "Weekly devbox dependencies update"
git push origin ${{ steps.generate_branch.outputs.BRANCH_NAME }} # Push branch
- name: Create Pull Request
if: steps.check_changes.outputs.CHANGES == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_URL=$(curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
-d '{"title":"Weekly Devbox Update","body":"This PR contains the weekly dependencies update for Devbox.","head":"${{ steps.generate_branch.outputs.BRANCH_NAME }}","base":"origin/CLOUDP-263321/unified-development-environment-devbox"}' \
https://api.github.com/repos/${{ github.repository }}/pulls | jq -r '.html_url')
echo "Pull request created: $PR_URL"