Skip to content

Instantly share code, notes, and snippets.

@WaKeMaTTa
Last active September 9, 2022 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WaKeMaTTa/8a7336638d4c1b2fcc20e4ba0d39e9fc to your computer and use it in GitHub Desktop.
Save WaKeMaTTa/8a7336638d4c1b2fcc20e4ba0d39e9fc to your computer and use it in GitHub Desktop.
This GitHub Workflow it will be executed when a GitHub Pull Request is merged in main git branch and it has changes inside config/locales. And his job is to creates and push copy changes in a phrase.com (main). If it fails, it sends a Slack message to the developers team.
# .github/workflows/02-merge-phrase-branch-in-to-phrase-main.yml
name: "Locales : Replicate git merge in phrase.com"
on:
pull_request:
branches:
- main
types:
- closed
paths:
- 'config/locales/**'
jobs:
build:
name: "Phrase : Merge Phrase branch with current Github branch"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
if: ${{ github.event.pull_request.merged == true && github.ref == 'main' && !startsWith(github.head_ref, 'auto-phrase-sync') }}
uses: actions/checkout@v3
- name: Push changes in phrase.com
if: ${{ github.event.pull_request.merged == true && github.ref == 'main' && !startsWith(github.head_ref, 'auto-phrase-sync') }}
run: |-
bin/phrase branches merge \
--project_id PASTE_YOUR_PROJECT_ID_HERE \
--name "${{ github.head_ref }}" \
--data "{\"strategy\": \"use_branch\"}"
- name: "Send a slack notification to #back-bot if job failed"
if: ${{ failure() }}
uses: slackapi/slack-github-action@v1
env:
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
SLACK_WEBHOOK_URL: "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX"
with:
payload: |-
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Phrase branch merge failed! :warning:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "• *Phrase branch*: <https://app.phrase.com/accounts/YOUR_ACCOUNT_NAME/projects/YOUR_PROJECT_NAME/dashboard?branch=${{ github.head_ref }}|`${{ github.head_ref }}`>\n• *Pull Request*: <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}>\n• *Owner*: ${{ github.actor }}"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment