-
Notifications
You must be signed in to change notification settings - Fork 1
107 lines (102 loc) · 3.68 KB
/
update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
name: Update
on:
schedule:
- cron: "0 11,23 * * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.config.outputs.branches }}
paths: ${{ steps.config.outputs.paths }}
steps:
- name: Checkout l10n:main
uses: actions/checkout@v4
with: { ref: main, fetch-depth: 0 }
- name: Refresh l10n:update
run: git push origin HEAD:update || true
- name: Get list of branches and paths
id: config
run: |
# Store the list of branches as a JSON array
echo "branches=$(jq -c '.branches' < .github/update-config.json)" >> "$GITHUB_OUTPUT"
# Store the list of paths as a multiline list
# Bash multiline version
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
{
echo 'paths<<EOF'
jq -r ".paths[]" < .github/update-config.json
echo EOF
} >> "$GITHUB_OUTPUT"
update:
needs: prepare
strategy:
max-parallel: 1
matrix:
ref: ${{ fromJSON(needs.prepare.outputs.branches) }}
runs-on: ubuntu-latest
steps:
- name: Checkout l10n:update
uses: actions/checkout@v4
with: { ref: update, path: l10n }
- name: Checkout firefox:${{ matrix.ref }}
uses: actions/checkout@v4
with:
repository: mozilla/gecko-dev
ref: ${{ matrix.ref }}
path: firefox
sparse-checkout: |
${{ needs.prepare.outputs.paths }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: l10n/.github/scripts/requirements.txt
- run: pip install -r l10n/.github/scripts/requirements.txt
- run: >
python .github/scripts/update.py
--branch ${{ matrix.ref }}
--commit $(cd ../firefox && git rev-parse --short HEAD)
--firefox ../firefox
--configs browser/locales/l10n.toml mobile/android/locales/l10n.toml
working-directory: l10n
- name: git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- run: git add .
working-directory: l10n
- name: git commit & push any changes
run: |
git diff-index --quiet HEAD || (git commit -F .update_msg && git push)
working-directory: l10n
cleanup:
needs: update
runs-on: ubuntu-latest
steps:
- name: Checkout l10n:update
uses: actions/checkout@v4
with: { ref: update }
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: .github/scripts/requirements.txt
- run: pip install -r .github/scripts/requirements.txt
- run: python .github/scripts/prune.py
- name: git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- run: git add .
- name: git commit & push any changes
run: git diff-index --quiet HEAD || (git commit -F .prune_msg && git push)
- run: gh pr create --base main --head update --title "Update messages" --body "" || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}