Minor edit #646
This file contains 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: Translation | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
on: | |
# pull_request: | |
# branches: [ main ] | |
# paths: | |
# - '**.en.json' # only take action when *.en.json files change | |
push: | |
branches: [ main ] | |
paths: | |
- '**.en.json' # only take action when *.en.json files change | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
translate: | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
# Get list of files that have been changed in the push | |
- id: files | |
uses: masesgroup/retrieve-changed-files@v2 | |
# Set variables that indicate whether XLSX files have been modified, which would indicate that | |
# this action has been triggered by an automated action | |
- id: automationresult | |
name: Verify whether this action is a result of another action | |
run: | | |
for input_file in ${{ steps.files.outputs.all }}; do | |
if [[ "$input_file" == *"xlsx" ]]; then | |
echo "Modification to XLSX file $input_file detected, this seems to be the output of an automated PR" | |
echo "excel_file_changed=yes" >> $GITHUB_OUTPUT | |
else | |
echo "$input_file is not an XLSX file" | |
fi | |
done | |
# Process the changed files | |
# Note that this step is not run if the previous step found an XLSX file modified | |
# (indicating that this action is the result of another action). Hence, this step | |
# wouldn't be run, not setting the variable `done_something`, so that the rest of | |
# the steps are not executed either. | |
- name: Work with the list of modified files - sort, update timestamp, translate | |
if: ${{ steps.automationresult.outputs.excel_file_changed != 'yes' }} | |
id: translate | |
env: | |
AZURE_TRANSLATOR_SUBSCRIPTION_KEY: ${{ secrets.AZURE_TRANSLATOR_SUBSCRIPTION_KEY }} | |
AZURE_TRANSLATOR_ENDPOINT: ${{ secrets.AZURE_TRANSLATOR_ENDPOINT }} | |
AZURE_TRANSLATOR_REGION: ${{ secrets.AZURE_TRANSLATOR_REGION }} | |
run: | | |
echo "DEBUG: steps.automationresult.outputs.excel_file_changed: ${{ steps.automationresult.outputs.excel_file_changed }}" | |
for input_file in ${{ steps.files.outputs.all }}; do | |
input_file_extension=${input_file: -7} | |
# Only process English checklists (.en.json) | |
if [[ "$input_file_extension" == "en.json" ]]; then | |
echo "Processing ${input_file}..." | |
echo "done_something=yes" >> $GITHUB_OUTPUT | |
# Sort modified file | |
python3 ./scripts/sort_checklist.py --input-file $input_file | |
# Update the timestamp in the modified file | |
python3 ./scripts/timestamp_checklist.py --input-file $input_file | |
# Translate modified file | |
python3 ./scripts/translate.py --input-file $input_file | |
fi | |
done | |
# Generate macro-free spreadsheets and Azure Monitor workbooks | |
- name: Setup python | |
if: ${{ steps.translate.outputs.done_something == 'yes' }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 #install the python needed | |
- name: Install dependencies | |
if: ${{ steps.translate.outputs.done_something == 'yes' }} | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests openpyxl | |
# Create Excel spreadsheets | |
- name: Execute excel python script # run file | |
if: ${{ steps.translate.outputs.done_something == 'yes' }} | |
run: | | |
python3 ./scripts/update_excel_openpyxl.py --checklist-file="${{ steps.files.outputs.all }}" --find-all --excel-file="./spreadsheet/macrofree/review_checklist_empty.xlsx" --output-name-is-input-name --output-path="./spreadsheet/macrofree/" --verbose | |
# Generate master (aka Godzilla) checklist, both JSON and Excel | |
- name: Create master checklist | |
if: ${{ steps.translate.outputs.done_something == 'yes' }} | |
run: | | |
python3 ./scripts/create_master_checklist.py --input-folder './checklists/' --language en --add-services --excel-file="./spreadsheet/macrofree/review_checklist_master_empty.xlsx" --output-name="checklist.en.master" --json-output-folder="./checklists/" --xlsx-output-folder="./spreadsheet/macrofree/" --verbose | |
# Generate WAF checklist, both JSON and Excel | |
- name: Create WAF checklist | |
if: ${{ steps.translate.outputs.done_something == 'yes' }} | |
run: | | |
for lan in "en" "es" "ja" "ko" "pt" "zh-Hant"; do | |
python3 ./scripts/create_master_checklist.py --waf --add-arm-services --service-dictionary ./scripts/service_dictionary.json --language $lan --input-folder './checklists/' --excel-file="./spreadsheet/macrofree/review_checklist_waf_empty.xlsx" --output-name="waf_checklist.${lan}" --json-output-folder="./checklists/" --xlsx-output-folder="./spreadsheet/macrofree/" --verbose | |
done | |
python3 ./scripts/merge_waf_checklists.py --review-checklist-file ./checklists/waf_checklist.en.json --aprl-checklist-file ./checklists-ext/aprl_checklist.en.json --sg-checklist-file ./checklists-ext/wafsg_checklist.en.json --output-file ./checklists-ext/fullwaf_checklist.en.json --service-dictionary ./scripts/service_dictionary.json --verbose | |
# Create Azure Monitor workbooks | |
- name: Execute workbook python script # run file | |
if: ${{ steps.translate.outputs.done_something == 'yes' }} | |
run: | | |
# Create workbooks for the modified file | |
python3 ./scripts/workbook_create.py --checklist-file="${{ steps.files.outputs.all }}" --output-path="./workbooks/" --blocks-path="./workbooks/blocks/" | |
python3 ./scripts/workbook_create.py --checklist-file="${{ steps.files.outputs.all }}" --output-path="./workbooks/" --blocks-path="./workbooks/blocks/" --counters | |
# Extra static commands to generate a network-specific ALZ workbook | |
python3 ./scripts/workbook_create.py --checklist-file ./checklists/alz_checklist.en.json --output-path ./workbooks --blocks-path ./workbooks/blocks --create-arm-template --category=network --query-size medium | |
python3 ./scripts/workbook_create.py --checklist-file ./checklists/alz_checklist.en.json --output-file ./workbooks/alz_checklist.en_network_counters.json --blocks-path ./workbooks/blocks --create-arm-template --category=network --query-size tiny --counters | |
python3 ./scripts/workbook_create.py --checklist-file ./checklists/alz_checklist.en.json --output-file ./workbooks/alz_checklist.en_network_tabcounters.json --blocks-path ./workbooks/blocks --create-arm-template --category=network --query-size tiny --tab-counters | |
# App delivery | |
python3 ./scripts/workbook_create.py --checklist-file ./checklists/network_appdelivery_checklist.en.json --output-file ./workbooks/appdelivery_checklist.en_network_workbook.json --blocks-path ./workbooks/blocks --create-arm-template --category=network --query-size tiny | |
python3 ./scripts/workbook_create.py --checklist-file ./checklists/network_appdelivery_checklist.en.json --output-file ./workbooks/appdelivery_checklist.en_network_counters_workbook.json --blocks-path ./workbooks/blocks --create-arm-template --category=network --query-size tiny --counters | |
# Create the PR if any change was made | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v6 | |
if: ${{ steps.translate.outputs.done_something == 'yes' }} | |
with: | |
title: 'Automatic translation of ${{ steps.files.outputs.all }}' | |
body: 'Processed changed files ${{ steps.files.outputs.all }}' | |
labels: 'automated' | |
token: ${{ secrets.WORKFLOW_PAT }} |