.github/workflows/main.yml #225
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
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 6 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo content | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5.0.0 | |
with: | |
cache: "pip" | |
- name: Install Python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Determine next edition | |
id: determine-edition | |
run: | | |
git fetch --tags | |
git fetch origin --tags | |
latest_git_tag=$(($(git tag | sort -n | tail -n 1))) | |
# Get the latest edition from Python script | |
latest_edition=$(python get_latest_edition.py) | |
if [ $? -eq 1 ]; then | |
echo "Error: Unable to get the latest edition. Exiting..." | |
exit 1 | |
fi | |
# Compare the outputs | |
if [ "$latest_git_tag" -eq "$latest_edition" ]; then | |
echo "Latest Git tag and latest edition are equal. Exiting workflow." | |
exit 1 | |
else | |
echo "Latest Git tag and latest edition are not equal. Continuing workflow." | |
# Continue with your workflow commands here | |
fi | |
echo "EDITION=$latest_edition" >> "$GITHUB_OUTPUT" | |
- name: Check if edition exists | |
id: check-edition | |
run: | | |
if wget -qO- "https://mailchi.mp/hackernewsletter/${{ steps.determine-edition.outputs.EDITION }}" | grep -q "trying to reach a page that was built by Mailchimp bu"; then | |
echo "Mailchimp page not found, exiting workflow." | |
exit 1 | |
elif wget --spider "https://mailchi.mp/hackernewsletter/${{ steps.determine-edition.outputs.EDITION }}" 2>&1 | grep -q "200 OK"; then | |
echo "Edition exists, continuing workflow." | |
else | |
echo "Edition does not exist, exiting workflow." | |
exit 1 | |
fi | |
- name: Setup Playwright | |
run: playwright install chromium | |
- name: Execute Python script | |
run: python generator.py ${{steps.determine-edition.outputs.EDITION }} | |
- name: Setup Tectonic | |
uses: WtfJoke/setup-tectonic@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Print Tectonic version | |
run: tectonic --version | |
- name: Run Tectonic | |
run: tectonic output.tex | |
- name: Rename output.pdf | |
run: mv output.pdf HackerNewsPaper-${{ steps.determine-edition.outputs.EDITION }}.pdf | |
- name: Upload a Build Artifact | |
if: always() | |
uses: actions/upload-artifact@v4.3.1 | |
with: | |
path: ./*.* | |
- name: Create release | |
uses: ncipollo/release-action@v1.14.0 | |
with: | |
allowUpdates: true | |
tag: ${{ steps.determine-edition.outputs.EDITION }} | |
name: "HackerNewsPaper #${{ steps.determine-edition.outputs.EDITION }}" | |
body: "HackerNewsPaper #${{ steps.determine-edition.outputs.EDITION }}" | |
artifacts: "HackerNewsPaper-${{ steps.determine-edition.outputs.EDITION }}.pdf" | |
removeArtifacts: true |