-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (68 loc) · 2.5 KB
/
update-mirror.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
name: Update mirror
on:
push:
branches:
- automation
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '42 */3 * * *'
workflow_dispatch: # allows to be run manually
# Allow one concurrent release
concurrency:
group: "default-branch-push"
env:
SOURGE_HG_REPO_URL: https://hg.mozilla.org/l10n-central/ar/
SOURCE_HG_REPO_PATH: source_hg_repo
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
ref: automation
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Cache Python dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/pip
!~/.cache/pip/log/debug.log
~/.local/bin
key: ${{ runner.os }}_pip_${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}_pip_
- name: Install dependencies
run: pip install --user -r requirements.txt
- name: Cache Mercurial repository clone - prepare cache key parts
id: cache_date
run: |
echo ::set-output name=YEAR::$(date +"%Y")
echo ::set-output name=MONTH::$(date +"%m")
echo ::set-output name=DAY::$(date +"%d")
- name: Cache Mercurial repository clone
uses: actions/cache@v3
with:
path: |
${{ env.SOURCE_HG_REPO_PATH }}
!${{ env.SOURCE_HG_REPO_PATH }}/.hg/hgrc
key: ${{ runner.os }}_${{ env.SOURCE_HG_REPO_PATH }}_${{ steps.cache_date.outputs.YEAR }}_${{ steps.cache_date.outputs.MONTH }}_${{ steps.cache_date.outputs.DAY }}
restore-keys: |
${{ runner.os }}_${{ env.SOURCE_HG_REPO_PATH }}_${{ steps.cache_date.outputs.YEAR }}_${{ steps.cache_date.outputs.MONTH }}_
- name: Update mirror
run: |
hg pull -u '${{ env.SOURGE_HG_REPO_URL }}'
hg update
hg bookmark -f default
hg \
--config auth.gh.prefix=github.com \
--config auth.gh.username=x-access-token \
--config auth.gh.password='${{ secrets.GITHUB_TOKEN }}' \
push 'https://github.com/${{ github.repository }}.git' || push_exit_code=$?
if [ -z $push_exit_code ]; then push_exit_code=0; fi
(($push_exit_code==0 || $push_exit_code==1)) || exit $push_exit_code
working-directory: ${{ env.SOURCE_HG_REPO_PATH }}