diff --git a/makefile b/.github/makefile similarity index 100% rename from makefile rename to .github/makefile diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index a52d80c..0511b9b 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -6,9 +6,12 @@ on: pull_request: workflow_dispatch: +# Permissions to check contents and open PR (release pleases) and update pages. permissions: contents: write pull-requests: write + pages: write + id-token: write jobs: test-website-build: @@ -58,13 +61,13 @@ jobs: # Set the env vars we use (version set for clarity). export DATE=$(date +%F) export VERSION="${VERSION}" - make prepare-markdown + make -f .github/makefile prepare-markdown env: VERSION: ${{ needs.release.outputs.tag }} # Create the PDF files. - name: Create PDF - run: make create-pdf + run: make -f .github/makefile create-pdf # Publish the PDF and intermediate markdown as an artifact. # - name: Publish PDF Artifact @@ -78,3 +81,28 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release upload "${{ needs.release.outputs.tag }}" --clobber hacker-laws.pdf hacker-laws.md + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Build Website + run: | + cd .github/website + make install + make build + cp -r build/. '../pages' + ls -al "../pages" + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: './.github/pages' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/release-on-tag.yaml b/.github/workflows/release-on-tag.yaml deleted file mode 100644 index 7c527d1..0000000 --- a/.github/workflows/release-on-tag.yaml +++ /dev/null @@ -1,69 +0,0 @@ -# This pipeline builds the PDF ebook on any tag starting with 'v'. -name: "Create Release" -on: - push: - tags: - - 'v*' - -jobs: - prepare-pdf: - # Focal Fossa. Please don't use 'latest' tags, it's an anti-pattern. - runs-on: ubuntu-20.04 - steps: - # Checkout the code. - - name: Checkout - uses: actions/checkout@v2 - - # Set a descriptive version. For PRs it'll be the short sha. - - name: Set Version - id: set_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - # Prepare the content files. - - name: Prepare Content - run: ./scripts/prepare-markdown-for-ebook.sh ${{ steps.set_version.outputs.VERSION }} - - # Create a PDF from the prepared markdown. - - name: Prepare PDF - uses: docker://pandoc/latex:2.9 - with: - args: "-V toc-title:\"Table Of Contents\" --toc --pdf-engine=pdflatex --standalone --output hacker-laws.pdf hacker-laws.md" - - # Publish the PDF artifact. - - name: Publish PDF Artifacts - uses: actions/upload-artifact@master - with: - name: hacker-laws.pdf - path: hacker-laws.pdf - - release: - needs: prepare-pdf - runs-on: ubuntu-20.04 - steps: - - name: Download artifact - uses: actions/download-artifact@v2 - with: - name: hacker-laws.pdf - - - name: Create Release - id: create-release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body: | - Hacker Laws E-Book - draft: false - prerelease: false - - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create-release.outputs.upload_url }} - asset_path: ./hacker-laws.pdf - asset_name: hacker-laws.pdf - asset_content_type: application/pdf diff --git a/README.md b/README.md index 654abf0..61f6660 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,3 @@ ---- -title: "Hacker Laws" -author: "Dave Kerr, github.com/dwmkerr/hacker-laws" -subtitle: "Laws, Theories, Principles, and Patterns that developers will find useful. ${VERSION}, ${DATE}." -version: ${VERSION} ---- -