Skip to content

Commit

Permalink
Merge docs/extract locales to CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Jun 11, 2024
1 parent e1e622c commit 175acce
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 81 deletions.
104 changes: 86 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,63 @@ on:
pull_request:
branches:
- master
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# different events on the same ref can run in parallel
# different refs on the same event can run in parallel
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name}}
cancel-in-progress: true

env:
docs_artifact: docs

jobs:
context:
runs-on: ubuntu-latest

outputs:
is_fork: ${{ steps.context.outputs.is_fork }}
is_dependabot: ${{ steps.context.outputs.is_dependabot }}
is_push_master: ${{ steps.context.outputs.is_push_master }}

steps:
- name: Log context
shell: bash
run: |
cat <<EOF
${{ toJSON(github) }}
EOF
- name: Set context
id: context
shell: bash
run: |
is_push_master="${{ github.event_name == 'push' && github.ref_name == 'master' }}"
is_dependabot="${{ startsWith(github.head_ref, 'dependabot')}}"
if [[ "${{ github.event_name }}" == 'pull_request' ]]; then
# repository on a pull request refers to the base which is always mozilla/addons-server
is_fork=${{ github.event.pull_request.head.repo.fork }}
else
# Repository on a push refers to the head which would be the fork
is_fork="${{ github.event.repository.fork }}"
fi
echo "github.event.repository.full_name ${{ github.event.repository.full_name }}"
# Represetns a push to the master branch
echo "is_push_master=$is_push_master" >> $GITHUB_OUTPUT
# Determines if the workflow is running on a fork
echo "is_fork=$is_fork" >> $GITHUB_OUTPUT
# Represents a dependabot Pull request
echo "is_dependabot=$is_dependabot" >> $GITHUB_OUTPUT
echo "event_name: ${{ github.event_name }}"
cat $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: context

outputs:
digest: ${{ steps.build.outputs.digest }}
Expand All @@ -24,7 +73,9 @@ jobs:
- uses: actions/checkout@v4

- name: Build Docker image
if: ${{ github.event.pull_request.head.repo.fork == false && github.actor != 'dependabot[bot]' }}
if: |
needs.context.outputs.is_fork == false &&
needs.context.outputs.is_dependabot == false
id: build
uses: ./.github/actions/build-docker
with:
Expand Down Expand Up @@ -98,7 +149,7 @@ jobs:
run: |
make lint-codestyle
docs:
docs_build:
runs-on: ubuntu-latest
needs: build

Expand All @@ -119,20 +170,37 @@ jobs:
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/_build/html'
# Keep this in sync with `docs.yml: deploy_docs` where we deploy the artifact
name: docs
name: ${{ env.docs_artifact }}

docs_deploy:
needs: context
if: ${{ needs.context.outputs.is_push_master && !needs.context.outputs.is_fork }}
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
artifact_name: ${{ env.docs_artifact }}

locales:
runs-on: ubuntu-latest
needs: build
needs: [build, context]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Check out on the fork if applicable
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Extract Locales
uses: ./.github/actions/run-docker
Expand All @@ -142,20 +210,22 @@ jobs:
compose_file: docker-compose.yml
run: make extract_locales

- name: Push Locales (dry-run)
- name: Push Locales (fork)
if: ${{ needs.context.outputs.is_fork }}
shell: bash
run: |
if [[ ${{ github.event.pull_request.head.repo.fork}} == 'true' ]]; then
echo """
echo """
Github actions are not authorized to push from workflows triggered by forks.
We cannot verify if the l10n extraction push will work or not.
Please submit a PR from the base repository if you are modifying l10n extraction scripts.
"""
"""
exit 0
fi
make push_locales ARGS="--dry-run"
- name: Push Locales
if: ${{ !needs.context.outputs.is_fork }}
shell: bash
run: |
args="${{ needs.context.outputs.is_push_master == true && '' || '--dry-run' }}"
make push_locales ARGS="${args}"
test_test_addons_versions_files_ratings:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -212,8 +282,6 @@ jobs:
steps:
- uses: actions/checkout@v4



- name: Test (test_static_assets)
uses: ./.github/actions/run-docker
with:
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/docs.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/extract-locales.yml

This file was deleted.

0 comments on commit 175acce

Please sign in to comment.