Skip to content

Commit f998eef

Browse files
willduranddiox
andauthored
ci: fix locale extraction job (#13804)
Co-authored-by: Mathieu Pillard <diox@users.noreply.github.com>
1 parent 044905c commit f998eef

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212

1313
outputs:
1414
is_fork: ${{ steps.context.outputs.is_fork }}
15+
is_default_branch: ${{ steps.context.outputs.is_default_branch }}
1516

1617
steps:
1718
- uses: actions/checkout@v5
@@ -27,7 +28,7 @@ jobs:
2728
fetch-depth: 0
2829
ref: ${{ github.event.pull_request.head.ref }}
2930
repository: ${{ github.event.pull_request.head.repo.full_name }}
30-
persist-credentials: false
31+
persist-credentials: ${{ needs.context.outputs.is_default_branch }}
3132

3233
- uses: actions/setup-node@v5
3334
with:
@@ -47,6 +48,10 @@ jobs:
4748
run: |
4849
event_name="${{ github.event_name }}"
4950
is_fork="${{ needs.context.outputs.is_fork }}"
51+
is_default_branch="${{ needs.context.outputs.is_default_branch }}"
52+
is_push="${{ github.event_name == 'push' }}"
53+
54+
# Keep this logic in sync with addons-server
5055
5156
if [[ "$is_fork" == 'true' ]]; then
5257
cat <<'EOF'
@@ -57,13 +62,10 @@ jobs:
5762
exit 0
5863
fi
5964
60-
ARGS=""
61-
62-
if [[ "$event_name" == 'pull_request' ]]; then
63-
ARGS="--dry-run"
65+
if [[ "$is_default_branch" == 'true' && "$is_push" == 'true' ]]; then
66+
args=""
67+
else
68+
args="--dry-run"
6469
fi
6570
66-
./bin/push-locales $ARGS
67-
68-
69-
71+
./bin/push-locales $args

bin/push-locales

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,20 @@ GIT_AUTHOR_EMAIL: $GIT_AUTHOR_EMAIL
5151
GIT_COMMITTER_NAME: $GIT_COMMITTER_NAME
5252
GIT_COMMITTER_EMAIL: $GIT_COMMITTER_EMAIL
5353
54-
This script passes arguments directly to Git commands. We can pass --dry-mode to test this script
55-
Without actually committing or pushing. Make sure to only pass arguments supported on both commit and push..
54+
This script passes arguments directly to Git commands. We can pass --dry-run to test this script.
55+
Without actually committing or pushing. Make sure to only pass arguments supported on both commit
56+
and push.
57+
5658
ARGS: $@
5759
"""
5860

5961
git commit -am "$MESSAGE" "$@"
62+
63+
if [[ "$@" =~ '--dry-run' ]]; then
64+
info """
65+
Skipping 'git push' because '--dry-run' is in ARGS so we should not have git credentials.
66+
"""
67+
exit 0
68+
fi
69+
6070
git push "$@"

0 commit comments

Comments
 (0)