Skip to content

Commit

Permalink
Add GitHub Pages deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Jun 24, 2024
1 parent b472a44 commit 928867d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 8 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: deploy

on:
push:
branches:
- main

# Enable running this workflow manually from the Actions tab
workflow_dispatch:

# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: pages
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: npm ci
- name: Build with Eleventy
run: npm run-script build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Folders to ignore
node_modules
public
_site
.DS_Store
11 changes: 7 additions & 4 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ module.exports = function (eleventyConfig) {
],
headingPermalinks: true,
header: {
organisationLogo: false,
logotype: false,
productName: 'Design history',
search: {
indexPath: '/search.json',
sitemapPath: '/sitemap'
}
}
},
url:
process.env.GITHUB_ACTIONS &&
'https://x-govuk.github.io/govuk-design-history-template/'
})

// Passthrough
Expand All @@ -26,9 +29,9 @@ module.exports = function (eleventyConfig) {
markdownTemplateEngine: 'njk',
dir: {
input: 'app',
output: 'public',
layouts: '_layouts',
includes: '_components'
}
},
pathPrefix: process.env.GITHUB_ACTIONS && '/govuk-design-history-template/'
}
}
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build]
command = "npm run build"
publish = "public"
publish = "_site"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"license": "MIT",
"scripts": {
"prebuild": "rimraf public",
"prebuild": "rimraf _site",
"build": "eleventy",
"start": "eleventy --serve --quiet",
"preserve": "npm run build",
Expand Down
2 changes: 1 addition & 1 deletion scripts/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function decoratePaths () {
paths.forEach(item => {
item.id = item.title.replace(/ +/g, '-').toLowerCase()
item.file = `${imageDirectory}/${item.id}.png`
item.src = item.file.replace('app/assets', '/public')
item.src = item.file.replace('app/assets', '/_site')
})
}

Expand Down

0 comments on commit 928867d

Please sign in to comment.