GitHub Actions
You are a developer and don’t want to keep track of when/how push and pull your project’s files using Accent? Use GitHub Actions to automatically keep your repository in-sync with your Accent project.
Push
This workflow runs on every push to your main
branch. It also means that it runs after every pull requests merged in main
. A couple of options have been added to ensure that the sync does not override anything that was touched bby a reviewer and that the translations (every files not in your main language) will also be pushed.
name: Accent push
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install -g accent-cli
- run: accent sync --add-translations --merge-type=passive
Pull
This workflow runs at the same time every day (you can also configure it to run anytime you want). It does the same thing as the Accent push
workflow but now it takes the changes to the repository and creates a pull request. You can then merge the branch when you want.
name: Accent sync
on:
schedule:
- cron: "0 4 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install -g accent-cli
- run: accent sync --add-translations --merge-type=passive --order-by=key
- uses: peter-evans/create-pull-request@v4
with:
add-paths: "*.po"
commit-message: Update Accent
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: accent
draft: false
delete-branch: true
title: New translations are available to merge
body: Translation files have been updated, feel free to merge this pull request after review.
Conclusion
You now have a fully automated and non-destructive workflow to keep your repository in sync with Accent :)