This GitHub Action allows you to automatically send preview build links from AWS Amplify from a GitHub pull request to a corresponding YouTrack issue. I did not find a direct integration, and it felt the easiest way to do this. The reason why somebody would want to attach preview links to issue is to streamline the collaboration process, specifically when sharing preview builds with QA and Design teams. This integration reduces the friction often experienced when cross-referencing between multiple platforms.
Here is the detailed setup using a GitHub Action's workflow:
name: Comment Trigger on: issue_comment: types: [created] jobs: check-comment: if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.user.login, 'aws-amplify-eu-central-1') # use your github app amplify user name runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Get comment, user, and PR branch env: GH_TOKEN: ${{ secrets.GH_API_TOKEN }} run: | echo "Comment: ${{ github.event.comment.body }}" echo "User: ${{ github.event.comment.user.login }}" BRANCH=$(curl -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} | jq -r '.head.ref') echo "PR branch: $BRANCH" echo "BRANCH=$BRANCH" >> $GITHUB_ENV - name: Process branch name and call YouTrack API env: YT_TOKEN: ${{ secrets.YOUTRACK_TOKEN }} YT_URL: ${{ secrets.YOUTRACK_URL }} run: | ISSUE_ID=$(echo $BRANCH | grep -o -E '^PRJ-[0-9]+') if [ -z "$ISSUE_ID" ]; then echo "Branch name does not follow the pattern PRJ-<ISSUE_NUMBER>-*. Completing the job." exit 0 fi echo "Issue id in YouTrack: $ISSUE_ID" COMMENT_TEXT="${{ github.event.comment.body }}" USER=${{ github.event.comment.user.login }} COMMENT_JSON="{ \"text\": \"Comment from GitHub user $USER: $COMMENT_TEXT\" }" curl -X POST -H "Authorization: Bearer $YT_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" -d "$COMMENT_JSON" $YT_URL/api/issues/$ISSUE_ID/comments
Here's a brief rundown:
- The action listens to
issue_comment
events on a GitHub repository. Theif
condition ensures that the action only responds to comments made on pull requests and from a specific GitHub user (AWS Amplify).
- The action checks out the repository code using the
actions/checkout@v2
action.
- It fetches the pull request branch name, comment, and the username of the commenter. This information is obtained from the GitHub API using an API token.
- Using the obtained branch name, the action extracts the YouTrack issue ID assuming the branch name follows a certain pattern (e.g.,
PRJ-<ISSUE_NUMBER>-*
).
- If the branch name follows the specified pattern, a POST request is made to the YouTrack API. This request sends the GitHub comment to the corresponding YouTrack issue. The request includes a JSON payload with the comment text and the username of the commenter. The YouTrack API requires an API token for authentication.
Sharing the AWS Amplify preview builds directly with the QA and Design teams enhances team collaboration by allowing immediate feedback on the development progress. This technique can be adapted for other platforms with APIs. Always remember to replace the placeholders with your own values.
How to get YouTrack token:
Â