forked from Quansight/ragna
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.41 KB
/
update-docker-requirements.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
name: docker-requirements
on:
push:
branches:
- main
workflow_dispatch:
permissions:
pull-requests: write
contents: write
jobs:
update:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup environment
uses: ./.github/actions/setup-env
with:
python-version: "3.11"
optional-dependencies: "false"
- name: Install GitHub CLI
run: sudo apt-get install gh
- name: Update docker requirements
id: update
run: |
pip-compile \
--quiet \
--strip-extras --output-file=requirements-docker.lock \
--extra=all pyproject.toml
NEEDS_UPDATE=$(git diff --quiet && echo 'false' || echo 'true')
echo "needs-update=${NEEDS_UPDATE}" | tee --append $GITHUB_OUTPUT
- name: Get last merged PR info
id: pr_info
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
LAST_MERGED_PR=$(gh pr list --repo $GITHUB_REPOSITORY --state closed --json number --jq '.[0].number')
echo "Last merged PR number: $LAST_MERGED_PR"
PR_INFO=$(gh pr view $LAST_MERGED_PR --repo $GITHUB_REPOSITORY --json author,mergedBy --jq '{author: .author.login, mergedBy: .mergedBy.login}')
echo "PR Info: $PR_INFO"
echo "pr_author=$(echo $PR_INFO | jq -r .author)" >> $GITHUB_ENV
echo "pr_mergedBy=$(echo $PR_INFO | jq -r .mergedBy)" >> $GITHUB_ENV
echo "PR Author: $(echo $PR_INFO | jq -r .author)"
echo "PR MergedBy: $(echo $PR_INFO | jq -r .mergedBy)"
- name: Open a PR to update the requirements
if: ${{ steps.update.outputs.needs-update }}
uses: peter-evans/create-pull-request@v5
with:
commit-message: update requirements-docker.lock
branch: update-docker-requirements
branch-suffix: timestamp
base: ${{ github.head_ref || github.ref_name }}
title: Update requirements-docker.lock
# prettier-ignore
body:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
reviewers: ${{ env.pr_author }},${{ env.pr_mergedBy }}
- name: Show diff
if: ${{ steps.update.outputs.needs-update }}
run: git diff --exit-code