-
Notifications
You must be signed in to change notification settings - Fork 7
71 lines (64 loc) · 2.44 KB
/
update-dependency-version.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
name: Check and update version of single dependency
on:
workflow_call:
inputs:
repo_url:
description: 'the repo url; currently only supports github repos'
required: true
type: string
current_tag:
description: 'the current repo ref (e.g. master, v1.0.0, etc.)'
required: true
type: string
env_var_name:
description: 'the environment variable to replace'
required: true
type: string
jobs:
check-and-update-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Parse the repo url (e.g. "https://github.com/bitcoin/bips") and extract:
# - the full repo name (e.g. "bitcoin/bips")
# - a short name (e.g. "bips")
- name: Prepare Repo Info
id: repoinfo
env:
REPO_URL: ${{ inputs.repo_url }}
run: |
echo "NAME=$(echo ${REPO_URL#*://*/})" >> $GITHUB_OUTPUT
echo "NAME_SHORT=$(echo ${REPO_URL##*://*/})" >> $GITHUB_OUTPUT
- name: Get Latest Releases
id: versions
env:
REPO_NAME: ${{ steps.repoinfo.outputs.NAME }}
run: |
echo "RELEASE_TAG=$(curl -sL "https://api.github.com/repos/${REPO_NAME}/releases/latest" | jq -r ".tag_name")" >> $GITHUB_OUTPUT
- name: Update Environment Variable
if: inputs.current_tag != steps.versions.outputs.RELEASE_TAG
env:
ENV_VARNAME: ${{ inputs.env_var_name }}
RELEASE_TAG: ${{ steps.versions.outputs.release_tag }}
run: |
sed -i "s/^$ENV_VARNAME=.*/$ENV_VARNAME=$RELEASE_TAG/g" .env
- name: Create Pull Request
if: steps.versions.outputs.RELEASE_TAG != '' && inputs.current_tag != steps.versions.outputs.RELEASE_TAG
env:
RELEASE_TAG: ${{ steps.versions.outputs.RELEASE_TAG }}
NAME: ${{ steps.repoinfo.outputs.NAME_SHORT }}
LINK: ${{ inputs.repo_url }}
uses: peter-evans/create-pull-request@v4
with:
add-paths: .env
branch: ${{ env.NAME }}-updates
delete-branch: true
commit-message: Update ${{ env.NAME }} to ${{ env.RELEASE_TAG }} (automated change)
title: Update ${{ env.NAME }} to ${{ env.RELEASE_TAG }}
body: |
Updates [${{ env.NAME }}][1] to ${{ env.RELEASE_TAG }}.
[1]: ${{ env.LINK }}
labels: |
automated pr
dependencies