-
Notifications
You must be signed in to change notification settings - Fork 2
128 lines (124 loc) · 4.92 KB
/
Copy pathupdate.yml
File metadata and controls
128 lines (124 loc) · 4.92 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# 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: "07 12 * * *"
workflow_dispatch:
permissions: {}
jobs:
prepare:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
branches: ${{ steps.config.outputs.branches }}
paths: ${{ steps.config.outputs.paths }}
steps:
- name: Checkout l10n:main
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: {ref: main, fetch-depth: 0, persist-credentials: false}
- name: Configure git credentials
run: git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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
permissions:
contents: write
steps:
- name: Checkout l10n:update
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: {ref: update, path: l10n, persist-credentials: false}
- name: Configure git credentials for l10n
run: git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
working-directory: l10n
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout thunderbird:${{ matrix.ref }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: thunderbird/comm-unified-l10n
ref: ${{ matrix.ref }}
path: thunderbird
persist-credentials: false
sparse-checkout: |
${{ needs.prepare.outputs.paths }}
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
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 "$BRANCH"
--commit $(cd ../thunderbird && git rev-parse --short HEAD)
--firefox ../thunderbird
--configs mail/locales/l10n.toml calendar/locales/l10n.toml
env:
BRANCH: ${{ matrix.ref }}
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
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout l10n:update
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with: {ref: update, persist-credentials: false}
- name: Configure git credentials
run: git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
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 }}