|
16 | 16 | runs-on: ubuntu-latest |
17 | 17 | permissions: |
18 | 18 | contents: write # Allow pushing the release branch |
| 19 | + outputs: |
| 20 | + release-branch-name: ${{ steps.define-release-branch.outputs.branch }} |
19 | 21 | steps: |
20 | 22 | - name: Determine tag |
21 | 23 | id: determine-tag |
|
31 | 33 | fi |
32 | 34 | echo "tag=${TAG}" >> "$GITHUB_OUTPUT" |
33 | 35 |
|
34 | | - - name: Define branch name from tag |
35 | | - id: define-branch |
| 36 | + - name: Define release branch name from tag |
| 37 | + id: define-release-branch |
36 | 38 | run: | |
37 | 39 | TAG=${{ steps.determine-tag.outputs.tag }} |
38 | 40 | echo "branch=release/${TAG%.0}.x" >> "$GITHUB_OUTPUT" |
|
43 | 45 | ref: ${{ steps.determine-tag.outputs.tag }} |
44 | 46 |
|
45 | 47 | - name: Check if branch already exists |
46 | | - id: check-branch |
| 48 | + id: check-release-branch |
47 | 49 | run: | |
48 | | - BRANCH=${{ steps.define-branch.outputs.branch }} |
| 50 | + BRANCH=${{ steps.define-release-branch.outputs.branch }} |
49 | 51 | if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then |
50 | 52 | echo "creating_new_branch=false" >> "$GITHUB_OUTPUT" |
51 | 53 | echo "Branch $BRANCH already exists - skipping creation" |
|
55 | 57 | fi |
56 | 58 |
|
57 | 59 | - name: Create and push release branch |
58 | | - if: steps.check-branch.outputs.creating_new_branch == 'true' |
| 60 | + if: steps.check-release-branch.outputs.creating_new_branch == 'true' |
59 | 61 | run: | |
60 | | - git checkout -b "${{ steps.define-branch.outputs.branch }}" |
61 | | - git push -u origin "${{ steps.define-branch.outputs.branch }}" |
| 62 | + git checkout -b "${{ steps.define-release-branch.outputs.branch }}" |
| 63 | + git push -u origin "${{ steps.define-release-branch.outputs.branch }}" |
| 64 | +
|
| 65 | + pin-system-tests: |
| 66 | + needs: create-release-branch |
| 67 | + runs-on: ubuntu-latest |
| 68 | + permissions: |
| 69 | + contents: write |
| 70 | + id-token: write # required for OIDC token federation |
| 71 | + steps: |
| 72 | + - uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3 |
| 73 | + id: octo-sts |
| 74 | + with: |
| 75 | + scope: DataDog/dd-trace-java |
| 76 | + policy: self.pin-system-tests.create-pr |
| 77 | + |
| 78 | + - name: Checkout dd-trace-java at release branch |
| 79 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2 |
| 80 | + with: |
| 81 | + ref: ${{ needs.create-release-branch.outputs.release-branch-name }} |
| 82 | + |
| 83 | + - name: Get latest commit SHA of base release branch |
| 84 | + id: get-latest-commit-sha |
| 85 | + run: | |
| 86 | + echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 87 | +
|
| 88 | + - name: Define pin-system-tests branch name |
| 89 | + id: define-pin-branch |
| 90 | + run: echo "branch=ci/pin-system-tests-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT |
| 91 | + |
| 92 | + - name: Check if pin-system-tests branch already exists |
| 93 | + id: check-pin-branch |
| 94 | + run: | |
| 95 | + BRANCH=${{ steps.define-pin-branch.outputs.branch }} |
| 96 | + if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then |
| 97 | + echo "ERROR: Branch $BRANCH already exists - please delete it and re-run the workflow." |
| 98 | + exit 1 |
| 99 | + else |
| 100 | + echo "Branch $BRANCH does not exist - creating it now." |
| 101 | + fi |
| 102 | + |
| 103 | + - name: Update system-tests references to latest commit SHA of system-tests main |
| 104 | + run: ./tooling/update_system_test_reference.sh |
| 105 | + |
| 106 | + - name: Check if changes should be committed |
| 107 | + id: check-changes |
| 108 | + run: | |
| 109 | + if [[ -z "$(git status -s)" ]]; then |
| 110 | + echo "ERROR: No changes to commit - the system-tests reference was not updated." |
| 111 | + exit 1 |
| 112 | + else |
| 113 | + echo "Changes to commit:" |
| 114 | + git status -s |
| 115 | + fi |
| 116 | + |
| 117 | + - name: Commit changes |
| 118 | + id: create-commit |
| 119 | + run: | |
| 120 | + git config user.name "github-actions[bot]" |
| 121 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 122 | + git commit -m "chore: Pin system-tests for release branch" .github/workflows/run-system-tests.yaml |
| 123 | + echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 124 | + |
| 125 | + - name: Push changes |
| 126 | + uses: DataDog/commit-headless@05d7b7ee023e2c7d01c47832d420c2503cd416f3 # action/v2.0.3 |
| 127 | + with: |
| 128 | + token: "${{ steps.octo-sts.outputs.token }}" |
| 129 | + branch: "${{ steps.define-pin-branch.outputs.branch }}" |
| 130 | + head-sha: "${{ steps.get-latest-commit-sha.outputs.sha }}" |
| 131 | + create-branch: true |
| 132 | + command: push |
| 133 | + commits: "${{ steps.create-commit.outputs.commit }}" |
| 134 | + |
| 135 | + - name: Create pull request |
| 136 | + env: |
| 137 | + GH_TOKEN: ${{ steps.octo-sts.outputs.token }} |
| 138 | + run: | |
| 139 | + gh pr create --title "Pin system tests for release branch" \ |
| 140 | + --base ${{ needs.create-release-branch.outputs.release-branch-name }} \ |
| 141 | + --head ${{ steps.define-pin-branch.outputs.branch }} \ |
| 142 | + --label "tag: dependencies" \ |
| 143 | + --label "tag: no release notes" \ |
| 144 | + --body "This PR pins the system-tests reference for the release branch." |
0 commit comments