-
Notifications
You must be signed in to change notification settings - Fork 1.3k
85 lines (73 loc) · 2.76 KB
/
version_getter_shared.yml
File metadata and controls
85 lines (73 loc) · 2.76 KB
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
80
81
82
83
84
85
on:
workflow_call:
inputs:
url:
required: true
type: string
file-name:
required: true
type: string
jobs:
reusable_workflow_job:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
fetch-version:
permissions:
contents: write # for git push
id-token: write # Needed to federate tokens.
runs-on: ubuntu-latest
name: Find latest version
steps:
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
id: octo-sts
with:
scope: DataDog/documentation
policy: self.version_getter_shared.create-pr
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: false
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.11"
- run: pip install requests semver defusedxml
- name: Find and write latest version
id: write-version
run: |
python local/bin/py/version_getter.py --url ${{ inputs.url }} --file-name ${{ inputs.file_name }}
- name: Save modified file
run: |
mkdir -p $RUNNER_TEMP/temp
cp ./data/{{ inputs.file_name }} $RUNNER_TEMP/temp/
- name: echo new version
run: echo ${{ steps.write-version.outputs.new_version }}
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: true
- name: Restore modified file
run: |
cp $RUNNER_TEMP/temp/{{ inputs.file_name }} ./data/
- name: Write version
if: steps.write-version.outputs.new_version == 'true'
run: |-
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ./data/{{ inputs.file_name }}
git commit -m "(Automated) Bump version"
git push -f origin HEAD:refs/heads/automatic-version-update/versions
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
name: Propose change with latest versions
if: steps.write-version.outputs.new_version == 'true'
with:
github-token: ${{ steps.octo-sts.outputs.token }}
result-encoding: string
script: |
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "(Automated) Bump version",
body: "### Merge instructions\n- [x] Please merge after reviewing",
head: "automatic-version-update/versions",
base: "master",
maintainer_can_modify: true
})