|
| 1 | +name: Create Release Branch and Pin System-Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]+.[0-9]+.0' # Trigger on minor release tags (e.g. v1.54.0) |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'The minor release tag (e.g. v1.54.0)' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +jobs: |
| 15 | + create-release-branch: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + id-token: write # Required for OIDC token federation |
| 20 | + steps: |
| 21 | + - uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3 |
| 22 | + id: octo-sts |
| 23 | + with: |
| 24 | + scope: DataDog/dd-trace-java |
| 25 | + policy: self.update-system-tests.push |
| 26 | + |
| 27 | + - name: Determine tag |
| 28 | + id: determine-tag |
| 29 | + run: | |
| 30 | + if [ -n "${{ github.event.inputs.tag }}" ]; then |
| 31 | + TAG=${{ github.event.inputs.tag }} |
| 32 | + else |
| 33 | + TAG=${GITHUB_REF#refs/tags/} |
| 34 | + fi |
| 35 | + if ! [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then |
| 36 | + echo "Error: Tag $TAG is not in the expected format: vX.Y.0" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" |
| 40 | +
|
| 41 | + - name: Define branch name from tag |
| 42 | + id: define-branch |
| 43 | + run: | |
| 44 | + TAG=${{ steps.determine-tag.outputs.tag }} |
| 45 | + BRANCH="release/${TAG%.0}.x" |
| 46 | + echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT" |
| 47 | +
|
| 48 | + - name: Checkout dd-trace-java |
| 49 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0 |
| 50 | + |
| 51 | + - name: Check if branch already exists |
| 52 | + id: check-branch |
| 53 | + run: | |
| 54 | + BRANCH=${{ steps.define-branch.outputs.branch }} |
| 55 | + if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then |
| 56 | + echo "creating_new_branch=false" >> "$GITHUB_OUTPUT" |
| 57 | + echo "Branch $BRANCH already exists - skipping following steps" |
| 58 | + else |
| 59 | + echo "creating_new_branch=true" >> "$GITHUB_OUTPUT" |
| 60 | + echo "Branch $BRANCH does not exist - proceeding with following steps" |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Update system-tests references to latest commit SHA on main |
| 64 | + if: steps.check-branch.outputs.creating_new_branch == 'true' |
| 65 | + run: BRANCH=main ./tooling/update_system_test_reference.sh |
| 66 | + |
| 67 | + - name: Commit changes |
| 68 | + if: steps.check-branch.outputs.creating_new_branch == '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 | + if: steps.check-branch.outputs.creating_new_branch == 'true' |
| 78 | + uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1 |
| 79 | + with: |
| 80 | + token: "${{ steps.octo-sts.outputs.token }}" |
| 81 | + branch: "${{ steps.define-branch.outputs.branch }}" |
| 82 | + branch-from: "${{ github.sha }}" |
| 83 | + command: push |
| 84 | + commits: "${{ steps.create-commit.outputs.commit }}" |
0 commit comments