-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
52 lines (47 loc) · 1.62 KB
/
action.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
name: "Dependascarbabot"
description: "A GitHub Action to automatically update Scarb.lock in Cairo repositories"
inputs:
github-token:
description: "GitHub token for authentication"
required: true
scarb-version:
description: "Version of scarb used to run 'scarb update'"
required: false
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ inputs.github-token }}
- name: Set up Scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: ${{ inputs.scarb-version }}
- name: Update dependencies
run: scarb update
shell: bash
- name: Create or update the PR
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if [ -n "$(git status --porcelain)" ]; then
COMMIT_HASH=$(git rev-parse HEAD)
BRANCH_NAME="update-scarb-lock-$COMMIT_HASH"
PR_URL=$(gh pr list --head "$BRANCH_NAME" --json url --jq '.[0].url')
if [ -n "$PR_URL" ]; then
echo "PR already exists"
else
git checkout -b $BRANCH_NAME
git add .
git commit -m "Update Scarb.lock"
git push -uf origin $BRANCH_NAME
gh pr create \
--title "Update Scarb.lock" \
--body $'This PR updates Scarb.lock from dependencies specified in Scarb.toml.' \
--base main --head $BRANCH_NAME
fi
fi
env:
GH_TOKEN: ${{ inputs.github-token }}
shell: bash