.github/workflows/main.yml #15
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: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo content | |
uses: actions/checkout@v3 | |
- name: Determine next edition | |
id: determine-edition | |
run: | | |
git fetch --tags | |
git fetch origin --tags | |
echo "EDITION=$(($(git describe --tags $(git rev-list --tags --max-count=1)) +1))" >> "$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 Python | |
uses: actions/setup-python@v4.7.0 | |
- name: Install Python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- 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@v2.1.1 | |
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@v3.1.2 | |
with: | |
path: ./*.* | |
- name: Create release | |
uses: ncipollo/release-action@v1.13.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 |