From e86a41b83d4c0a51ff8ed2d56fdaf2e83429a19d Mon Sep 17 00:00:00 2001 From: Jens L Date: Wed, 26 Jul 2023 10:57:08 +0200 Subject: [PATCH] ci: automatically rename transifex PRs to match the naming scheme (#6352) * ci: automatically rename transifex PRs to match the naming scheme Signed-off-by: Jens Langhammer * add name Signed-off-by: Jens Langhammer --------- Signed-off-by: Jens Langhammer --- .github/workflows/translation-rename.yml | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/translation-rename.yml diff --git a/.github/workflows/translation-rename.yml b/.github/workflows/translation-rename.yml new file mode 100644 index 000000000..def55adbc --- /dev/null +++ b/.github/workflows/translation-rename.yml @@ -0,0 +1,39 @@ +# Rename transifex pull requests to have a correct naming +name: authentik-translation-transifex-rename + +on: + pull_request: + types: [opened, reopened] + +jobs: + rename_pr: + runs-on: ubuntu-latest + if: ${{ github.event.sender.login == 'transifex-integration[bot]'}} + steps: + - id: generate_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.GH_APP_ID }} + private_key: ${{ secrets.GH_APP_PRIVATE_KEY }} + - name: Get current title + id: title + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + title=$(curl -q -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GH_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }} | jq -r .title) + echo "title=${title}" >> "$GITHUB_OUTPUT" + - name: Rename + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + curl -L \ + -X PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GH_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }} \ + -d "{\"title\":\"translate: ${{ steps.title.outputs.title }}\"}"