.github/workflows/main.yml #3
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: Fetch last tag | |
id: fetch-tag | |
run: echo "::set-output name=TAG::$(git describe --tags --abbrev=0)" | |
- name: Determine next edition | |
id: determine-edition | |
run: | | |
echo "::set-output name=EDITION::$(( ${TAG} + 1 ))" | |
- name: Check if edition exists | |
id: check-edition | |
run: | | |
if curl -I "https://mailchi.mp/hackernewsletter/${{ steps.determine-edition.outputs.EDITION }}" | 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 |