Update translations #152
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Prerelease | |
on: | |
pull_request: | |
types: | |
- opened | |
- labeled | |
- synchronize | |
permissions: | |
pull-requests: write | |
issues: write | |
jobs: | |
generate-matrix: | |
if: | | |
github.event_name == 'pull_request' && | |
(contains(github.event.pull_request.labels.*.name, 'prerelease') || | |
contains(toJSON(github.event.pull_request.labels.*.name), 'prerelease:')) | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v4.4.0 | |
with: | |
node-version-file: .nvmrc | |
- name: Generate matrix from locales config | |
id: set-matrix | |
run: | | |
LABELS_JSON='${{ toJson(github.event.pull_request.labels.*.name) }}' | |
echo "LABELS_JSON: $LABELS_JSON" | |
# Use Node.js script to generate matrix | |
OUTPUT=$(node .github/scripts/generate-prerelease-matrix.js "$LABELS_JSON") | |
echo "$OUTPUT" >> $GITHUB_OUTPUT | |
echo "Generated matrix output: $OUTPUT" | |
test: | |
needs: generate-matrix | |
if: needs.generate-matrix.outputs.matrix != '{"include":[]}' | |
uses: ./.github/workflows/test-e2e.yml | |
with: | |
matrix-include: ${{ toJson(fromJson(needs.generate-matrix.outputs.matrix).include) }} | |
secrets: inherit | |
deploy: | |
needs: generate-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
name: Deploy ${{ matrix.locale }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
ref: ${{ github.head_ref }} | |
- name: Log checked out commit | |
run: git log -1 | |
- uses: ./.github/actions/setup | |
- uses: ./.github/actions/vercel-pull | |
with: | |
environment: preview | |
vercel_project_id: ${{ secrets[matrix.secret_project_id] }} | |
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }} | |
vercel_token: ${{ secrets.VERCEL_TOKEN }} | |
- uses: ./.github/actions/vercel-build | |
with: | |
environment: preview | |
vercel_project_id: ${{ secrets[matrix.secret_project_id] }} | |
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }} | |
vercel_token: ${{ secrets.VERCEL_TOKEN }} | |
- id: deploy | |
uses: ./.github/actions/vercel-deploy | |
with: | |
environment: preview | |
vercel_project_id: ${{ secrets[matrix.secret_project_id] }} | |
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }} | |
vercel_token: ${{ secrets.VERCEL_TOKEN }} | |
- name: Set deploy outputs | |
id: set_outputs | |
run: | | |
echo "preview_url=${{ steps.deploy.outputs.prod_url }}" >> $GITHUB_OUTPUT | |
echo "inspect_url=${{ steps.deploy.outputs.inspect_url }}" >> $GITHUB_OUTPUT | |
echo "label=${{ matrix.locale }}" >> $GITHUB_OUTPUT | |
- name: Write deploy result to file | |
run: | | |
jq -n \ | |
--arg label "${{ steps.set_outputs.outputs.label }}" \ | |
--arg preview_url "${{ steps.set_outputs.outputs.preview_url }}" \ | |
--arg inspect_url "${{ steps.set_outputs.outputs.inspect_url }}" \ | |
'{label: $label, preview_url: $preview_url, inspect_url: $inspect_url}' > deploy-result.json | |
- name: Upload deploy result artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: deploy-result-${{ matrix.locale }} | |
path: deploy-result.json | |
comment-vercel-previews: | |
needs: [generate-matrix, deploy] | |
name: Comment Vercel Previews | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Download all deploy result artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: deploy-result-* | |
path: deploy-results | |
- name: Combine deploy results | |
id: aggregate | |
run: | | |
jq -s '.' deploy-results/deploy-result-*/deploy-result.json > deploy-results.json | |
- name: Check if deploy results exist | |
id: check_results | |
run: | | |
if [ -f deploy-results.json ] && [ $(jq length deploy-results.json) -gt 0 ]; then | |
echo "has_results=true" >> $GITHUB_OUTPUT | |
else | |
echo "has_results=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Comment PR with all Vercel Preview Links | |
if: | | |
success() && hashFiles('deploy-results.json') != '' && steps.check_results.outputs.has_results == 'true' | |
uses: ./.github/actions/comment-vercel-preview | |
with: | |
deploy_results_path: deploy-results.json |