-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (66 loc) · 3.02 KB
/
ci_automerge_dependabot.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: CI - Activate auto-merging for Dependabot PRs
on:
pull_request_target:
branches: [ci/dependabot-updates]
jobs:
update-dependabot-branch:
name: Update permanent dependabot branch
if: github.repository_owner == 'CasperWA' && startsWith(github.event.pull_request.head.ref, 'dependabot/') && github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
env:
DEPENDABOT_BRANCH: ci/dependabot-updates
GIT_USER_NAME: CasperWA
GIT_USER_EMAIL: "[email protected]"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
persist-credentials: false
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Set up git user info
run: |
git config --global user.name "${{ env.GIT_USER_NAME }}"
git config --global user.email "${{ env.GIT_USER_EMAIL }}"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
while IFS="" read -r line || [ -n "${line}" ]; do
if [[ "${line}" =~ ^invoke.*$ ]]; then
invoke="${line}"
fi
done < requirements_docs.txt
pip install ${invoke}
pip install -r requirements.txt
pip install .
- name: Run tasks (and commit)
run: |
invoke update-pytest-reqs
invoke create-canonized-test-file
git add pyproject.toml tests/static/rdflib_canonized
if [ -n "$(git status --porcelain pyproject.toml tests/static/rdflib_canonized)" ]; then
# Only commit if there's something to commit (git will return non-zero otherwise)
echo "Committing update to pytest dependency config and/or RDFlib version-specific canonized test file !"
git commit -m "Update version-specific parts\n\nUpdate pytest dependency config and/or\nRDFlib version-specific canonized test file"
echo "PUSH_BACK_TO_BRANCH=true" >> $GITHUB_ENV
else
echo "No changes to pytest dependency config and/or RDFlib version-specific canonized test file."
echo "PUSH_BACK_TO_BRANCH=false" >> $GITHUB_ENV
fi
- name: Update Dependabot branch
if: env.PUSH_BACK_TO_BRANCH == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.RELEASE_PAT }}
branch: ${{ github.event.pull_request.head.ref }}
- name: Activate auto-merge
run: |
PR_ID="$(gh api graphql -F owner='{owner}' -F name='{repo}' -f query='query($owner: String!, $name: String!) {repository(owner: $owner, name: $name) {pullRequest(number: ${{ github.event.pull_request.number }}) {id}}}' --jq '.data.repository.pullRequest.id')"
gh api graphql -f pr_id="$PR_ID" -f query='mutation($pr_id: ID!) {enablePullRequestAutoMerge(input:{mergeMethod:SQUASH,pullRequestId:$pr_id }) {pullRequest {number}}}'
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}