Skip to content

Generate This Week in Rust #10

Generate This Week in Rust

Generate This Week in Rust #10

name: Generate This Week in Rust
on:
workflow_dispatch:
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: curl "https://raw.githubusercontent.com/rust-lang/this-week-in-rust/master/content/$DATE-this-week-in-rust.md" --fail-with-body -o "$DATE-tmp.md"
- name: Remove Unnecesary Lines
run: tail -n +6 "$DATE-tmp.md" > "$DATE-tmp.md"
- name: Add emoji
run: sed -i -e 's/## Updates from Rust Community/## Updates from Rust Community 🥰/g' "$DATE-tmp.md"
- name: Set Output Content File
id: output_file
run: |
CONTENT=$(cat "$DATE-tmp.md")
echo "content=$CONTENT">>$GITHUB_ENV
echo "${{env.content}}"
# Translate process
- uses: fabasoad/translation-action@main
id: translation_step
with:
provider: google
lang: en-es
source: ${{ env.content }}
- 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 #1\"">>"$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