Skip to content

Generate This Week in Rust #16

Generate This Week in Rust

Generate This Week in Rust #16

name: Generate This Week in Rust
on:
workflow_dispatch:
inputs:
MS_TRANSLATE_API_KEY:
description: Esta es la API con la que se conecta con el servicio
required: true
type: string
MS_TRANSLATE_API_ENDPOINT:
description: Esta es la URL de la API a la que se conecta
required: true
type: string
MS_TRANSLATE_REGION:
description: Esta es la region a la que se conecta con el servicio
required: true
type: string
schedule:
- cron: "0 0 * * *"
jobs:
get:
name: Get Original article
runs-on: ubuntu-22.04
outputs:
content: ${{ steps.output_file.outputs.content }}
steps:
- uses: actions/checkout@v3
- name: Define Current Date
run: |
# export CURR_DATE=$(date +%F)
echo 'DATE=2023-10-18'>>$GITHUB_ENV
- name: Download the Article
id: download_article
run: |
wget "https://raw.githubusercontent.com/rust-lang/this-week-in-rust/master/content/$DATE-this-week-in-rust.md" -O "$DATE-tmp.md"
- name: Remove Unnecesary Lines
run: tail -n +6 "$DATE-tmp.md">$DATE.md
- name: Add emoji
run: sed -i -e 's/## Updates from Rust Community/## Updates from Rust Community 🥰/g' "$DATE.md"
# Translate process
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Translate File
env:
API_ENDPOINT: ${{ github.event.inputs.MS_TRANSLATE_API_ENDPOINT }}
API_KEY: ${{ github.event.inputs.MS_TRANSLATE_API_KEY }}
REGION: ${{ github.event.inputs.MS_TRANSLATE_REGION }}
run: |
pip install uuid requests
python3 gen_translated.py ${{ env.DATE }}.md
- name: Create Translated File
run: |
week=$(ls esta_semana_en_rust | wc -l);
week=$((week + 1));
echo "---">"$DATE-this-week-in-rust.md"
echo "title: \"Esta semana en Rust #$week\"">>"$DATE-this-week-in-rust.md"
echo "number_of_week: $week">>"$DATE-this-week-in-rust.md"
echo "description: Esta semana en Rust es un blog semanal sobre el lenguaje de programación Rust, sus comunidades y su ecosistema.">>"$DATE-this-week-in-rust.md"
echo "date: $DATE">>"$DATE-this-week-in-rust.md"
echo "tags:">>"$DATE-this-week-in-rust.md"
echo " - rust">>"$DATE-this-week-in-rust.md"
echo " - comunidad">>"$DATE-this-week-in-rust.md"
echo ' - "esta semana en rust"'>>"$DATE-this-week-in-rust.md"
echo -e "---\n">>"$DATE-this-week-in-rust.md"
echo "${{ steps.translation_step.outputs.text }}">>"$DATE-this-week-in-rust.md"
# Just for test
- uses: actions/upload-artifact@v3
with:
name: ${{ env.DATE }}
path: ${{ env.DATE }}-this-week-in-rust.md