Skip to content

ci: use gh app for creating ephemeral tokens #57

ci: use gh app for creating ephemeral tokens

ci: use gh app for creating ephemeral tokens #57

name: Update version branch
#When a release is done, this creates a PR from main to the released version branch to keep it updated.
#For example, if version "0.1.0" is released off of the main branch, then a PR from "main" to "0.x" will be created right after the release post-deploy is done.
on:
pull_request:
types:
- closed
permissions:
contents: read
jobs:
if_merged_postDeploy:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'post-release/')
runs-on: ubuntu-latest
name: Create PR to update version branch
steps:
- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"contents": "write",
"pull_requests": "write"
}
repositories: >-
["apm-agent-android"]
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.get_token.outputs.token }}
- uses: elastic/oblt-actions/git/setup@v1
with:
github-token: ${{ steps.get_token.outputs.token }}
- uses: actions-ecosystem/action-regex-match@v2
id: major-version
with:
text: ${{ github.event.pull_request.head.ref }}
regex: 'post-release/(\d+).+'
- run: |
CONFLICT_RESOLUTION_BRANCH="post-release/main-to-${{ env.BASE_BRANCH }}"
git switch ${{ env.BASE_BRANCH }}
git checkout -b $CONFLICT_RESOLUTION_BRANCH
git merge main --strategy-option theirs
git push -u origin $CONFLICT_RESOLUTION_BRANCH
gh pr create --base ${{ env.BASE_BRANCH }} --title 'Merge main into version branch' --body 'Created by Github action :robot:' --reviewer elastic/apm-agent-android
env:
GH_TOKEN: ${{ steps.get_token.outputs.token }}
BASE_BRANCH: "${{ steps.major-version.outputs.group1 }}.x"