Skip to content

Generate This Week in Rust #102

Generate This Week in Rust

Generate This Week in Rust #102

name: Generate This Week in Rust
on:
workflow_dispatch:
inputs:
CUSTOM_DATE:
type: string
description: En caso de que se necesite ejecutar una fecha puntual
schedule:
- cron: "0 0 * * 6"
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: |
tmp_date=${{ github.event.inputs.CUSTOM_DATE }}
if [ ! -z "$tmp_date" -a "$tmp_date" != " " ]; then
echo "DATE=$tmp_date">>$GITHUB_ENV
exit 0
fi
export CURR_DATE=$(date -d "3 days ago" +%F)
echo "DATE=$CURR_DATE">>$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
# Translate process
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- 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"
- name: Show folder!
run: |
ls -la
echo "----"
echo "Seteo permisos"
chmod 777 "./$DATE-this-week-in-rust.md"
echo "----"
ls -la
- name: Translate File
id: translation_step
env:
API_ENDPOINT: ${{ secrets.MS_TRANSLATE_API_ENDPOINT }}
API_KEY: ${{ secrets.MS_TRANSLATE_API_KEY }}
REGION: ${{ secrets.MS_TRANSLATE_REGION }}
run: |
pip install uuid requests
python3 gen_translated.py
- name: Fixes
run: |
sed -i -e 's/## Actualizaciones de la comunidad de Rust/## Actualizaciones de la comunidad de Rust 🥰/g' "$DATE-this-week-in-rust.md"
sed -i -e 's/] (http/](http/g' "$DATE-this-week-in-rust.md"
sed -i -e 's/Óxido/Rust/g' "$DATE-this-week-in-rust.md"
sed -i -e 's/óxido/Rust/g' "$DATE-this-week-in-rust.md"
sed -i -e 's/## Caja de la semana/## Crate de la semana/g' "$DATE-this-week-in-rust.md"
sed -i -e 's/La caja de esta semana/El crate de esta semana/g' "$DATE-this-week-in-rust.md"
mv "$DATE-this-week-in-rust.md" "./esta_semana_en_rust/$DATE-this-week-in-rust.md"
- name: Commit report
run: |
week=$(ls esta_semana_en_rust | wc -l);
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add esta_semana_en_rust/*.md
git commit -am "Semana $week publicada"
git push