Generate This Week in Rust #1
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: 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: | |
- name: Define Current Date | |
run: | | |
# export CURR_DATE=$(date +%F) | |
export CURR_DATE="2023-10-18" | |
echo "::set-env name=DATE::$CURR_DATE" | |
- 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_OUTPUT" | |
translate: | |
runs-on: ubuntu-22.04 | |
needs: [get] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Define Current Date | |
run: | | |
# export CURR_DATE=$(date +%F) | |
export CURR_DATE="2023-10-18" | |
echo "::set-env name=DATE::$CURR_DATE" | |
- uses: fabasoad/translation-action@main | |
id: translation_step | |
with: | |
provider: google | |
lang: en-es | |
source: ${{ needs.get.outputs.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.CURR_DATE }} | |
path: ${{ env.CURR_DATE }}-this-week-in-rust.md |