Repository navigation
99 lines (83 loc) · 3.01 KB
/
Copy pathchangelog.yml
File metadata and controls
99 lines (83 loc) · 3.01 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Update changelog
on:
workflow_dispatch: {}
schedule:
- cron: '00 03 2 * *'
jobs:
changelog:
name: Update changelog
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
id-token: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
fetch-depth: 0
- name: Install runner
uses: ./.github/actions/install_runner
- name: Run script
run: |
chmod +x utils/scripts/update_change_log.sh
source venv/bin/activate
./utils/scripts/update_change_log.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
# Set the git user.
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Add files
run: |
git add "CHANGELOG.md"
- name: Variables
id: vars
run: |
BRANCH_NAME="auto-changelog-update"
echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
- name: Create branch
run: |
echo "Creating branch ${{ steps.vars.outputs.branch_name }}..."
git checkout -B ${{ steps.vars.outputs.branch_name }}
echo "Authenticating with GitHub CLI..."
gh auth setup-git
echo "Pushing empty branch ${{ steps.vars.outputs.branch_name }}..."
git push --force-with-lease -u origin ${{ steps.vars.outputs.branch_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create commit
run: |
echo "Committing..."
git commit -m "Update changelog" --no-verify
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
id: octo-sts
with:
scope: DataDog/system-tests
policy: self.changelog
- name: Push signed commits
uses: Asana/push-signed-commits@418a702ed822d75f534f2913c5b60e4e5242dd57
with:
github-token: ${{ steps.octo-sts.outputs.token }}
repo: DataDog/system-tests
local_branch_name: ${{ steps.vars.outputs.branch_name }}
remote_name: origin
remote_branch_name: ${{ steps.vars.outputs.branch_name }}
python-version: "3.12"
- name: Create Pull Request
run: |
BRANCH_NAME="${{ steps.vars.outputs.branch_name }}"
# Create or reference PR
if gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' | grep -q .; then
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number')
echo "PR already exists: #$PR_NUMBER"
else
gh pr create \
--title "Auto-update changelog" \
--body "Automated update of CHANGELOG.md" \
--head "$BRANCH_NAME" \
--base main
fi
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}