Skip to content

Commit

Permalink
ci: wip auto-generated week in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRibera committed Oct 24, 2023
1 parent a7306ed commit 8415ff1
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/this_week_in_rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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

0 comments on commit 8415ff1

Please sign in to comment.