Skip to content

Commit df84fee

Browse files
committed
Add pin system tests workflow
1 parent 015be6d commit df84fee

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Pin system tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'The minor release tag (e.g. v1.54.0)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
pin-system-tests:
13+
name: "Pin system tests"
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write # may not be needed
17+
id-token: write # Required for OIDC token federation
18+
steps:
19+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
20+
id: octo-sts
21+
with:
22+
scope: DataDog/dd-trace-java
23+
policy: self.pin-system-tests.create-pr
24+
25+
- name: Checkout the repository
26+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
27+
28+
- name: Define branch name
29+
id: define-branch
30+
run: echo "branch=ci/pin-system-tests-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
31+
32+
- name: Check if branch already exists
33+
id: check-branch
34+
run: |
35+
BRANCH=${{ steps.define-branch.outputs.branch }}
36+
if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
37+
echo "creating_new_branch=false" >> "$GITHUB_OUTPUT"
38+
echo "Branch $BRANCH already exists - skipping creation"
39+
else
40+
echo "creating_new_branch=true" >> "$GITHUB_OUTPUT"
41+
echo "Branch $BRANCH does not exist - creating it now"
42+
fi
43+
44+
- name: Create and push branch
45+
if: steps.check-branch.outputs.creating_new_branch == 'true'
46+
id: create-branch
47+
run: |
48+
git checkout -b "${{ steps.define-branch.outputs.branch }}"
49+
git push -u origin "${{ steps.define-branch.outputs.branch }}"
50+
51+
- name: Update system-tests references to latest commit SHA on main
52+
run: ./tooling/update_system_test_reference.sh
53+
54+
- name: Check if changes should be committed
55+
id: check-changes
56+
run: |
57+
if [[ -z "$(git status -s)" ]]; then
58+
echo "No changes to commit, exiting."
59+
echo "commit_changes=false" >> "$GITHUB_OUTPUT"
60+
exit 0
61+
else
62+
echo "commit_changes=true" >> "$GITHUB_OUTPUT"
63+
echo "Changes to commit:"
64+
git status -s
65+
fi
66+
67+
- name: Commit changes
68+
if: steps.check-changes.outputs.commit_changes == 'true'
69+
id: create-commit
70+
run: |
71+
git config user.name "github-actions[bot]"
72+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
73+
git commit -m "chore: Pin system-tests for release branch" .github/workflows/run-system-tests.yaml
74+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
75+
76+
- name: Push changes
77+
uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1
78+
if: steps.check-changes.outputs.commit_changes == 'true'
79+
with:
80+
token: "${{ steps.octo-sts.outputs.token }}"
81+
branch: "${{ steps.define-branch.outputs.branch }}"
82+
command: push
83+
commits: "${{ steps.create-commit.outputs.commit }}"
84+
85+
- name: Create pull request
86+
if: steps.check-changes.outputs.commit_changes == 'true'
87+
env:
88+
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
89+
# base may need to be `release/v*`
90+
run: |
91+
gh pr create --title "Pin system tests for release branch" \
92+
--base master \
93+
--head ${{ steps.define-branch.outputs.branch }} \
94+
--label "tag: dependencies" \
95+
--label "tag: no release notes" \
96+
--body "This PR pins the system-tests reference for the release branch."

0 commit comments

Comments
 (0)