-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
2,818 additions
and
175 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
* | ||
|
||
!manifest.webmanifest | ||
!sw.js | ||
|
||
!*.html | ||
!*.png | ||
!*.svg | ||
!*.xml | ||
|
||
!audio | ||
!css | ||
!data | ||
!fonts | ||
!icon | ||
!image | ||
!img | ||
!js | ||
!lib | ||
!search |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [[ $# -eq 0 ]]; then | ||
echo "No arguments provided. Usage: add-query-strings.sh <version>" | ||
exit 1 | ||
fi | ||
|
||
version=$1 | ||
|
||
# Set the IS_DEPLOYED variable for production. | ||
sed -i 's/IS_DEPLOYED\s*=\s*undefined/IS_DEPLOYED='"\"${version}\""'/g' js/utils.js | ||
|
||
|
||
echo "Installing Query Strings." | ||
|
||
# JS files | ||
for file in js/*; do | ||
find . -maxdepth 1 -type f -name '*.html' -print0 | | ||
while IFS= read -r -d $'\0' line; do | ||
sed -i -e "s;$file;$file?v=${version};g" $line | ||
done | ||
done | ||
|
||
# Handle the unique service worker .js strings | ||
find . -maxdepth 1 -type f -name '*.html' -print0 | | ||
while IFS= read -r -d $'\0' line; do | ||
sed -i -e "s;/sw.js;/sw.js?v=${version};g" $line | ||
done | ||
|
||
# CSS files | ||
for file in css/*; do | ||
find . -maxdepth 1 -type f -name '*.html' -print0 | | ||
while IFS= read -r -d $'\0' line; do | ||
sed -i -e "s;$file;$file?v=${version};g" $line | ||
done | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [[ $# -eq 0 ]]; then | ||
echo "No arguments provided. Usage: set-deployed-flag.sh <version>" | ||
exit 1 | ||
fi | ||
|
||
version=$1 | ||
|
||
# Set the IS_DEPLOYED variable for production. | ||
sed -i 's/IS_DEPLOYED\s*=\s*undefined/IS_DEPLOYED='"\"${version}\""'/g' js/utils.js |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Build and Deploy | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v**' | ||
|
||
env: | ||
# See: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio | ||
IMAGE_NAME: pf2etools | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
# See: https://stackoverflow.com/a/58178121 | ||
- name: Set Env | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Archive Release | ||
run: | | ||
zip -r pf2ools-${{ env.RELEASE_VERSION }}.zip . -x '*.git*' '*node_modules*' '*.github*' '*img*' '*.editorconfig*' '*CNAME*' | ||
- name: Set Deployed Flag | ||
run: | | ||
bash ./.github/set-deployed-flag.sh ${{ env.RELEASE_VERSION }} | ||
# Remove entries from the `.gitignore` so the gh-pages action can correctly add+commit them to the pages branch | ||
- name: Build Service Worker | ||
run: | | ||
node --version | ||
npm --version | ||
npm i | ||
npm run build:sw:prod | ||
sed -i 's/sw.js//g' .gitignore | ||
sed -i 's/sw-injector.js//g' .gitignore | ||
- name: Build SEO Pages | ||
env: | ||
VET_BASE_SITE_URL: https://pf2etools.com/ | ||
VET_SEO_IS_SKIP_UA_ETC: true | ||
run: | | ||
npm run build:seo -- ${{ env.RELEASE_VERSION }} | ||
# See: https://github.com/JamesIves/github-pages-deploy-action | ||
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@releases/v4 | ||
with: | ||
branch: prod | ||
folder: . | ||
|
||
- name: Archive Images | ||
run: | | ||
zip -r -s 500m img-${{ env.RELEASE_VERSION }}.zip img/ | ||
- name: Upload Release | ||
# Add the files one-by-one in an effort to avoid timeouts | ||
run: | | ||
hub release create -a pf2ools-${{ env.RELEASE_VERSION }}.zip -m ${{ env.RELEASE_VERSION }} ${{ env.RELEASE_VERSION }} | ||
for f in $(find . -name 'img-${{ env.RELEASE_VERSION }}.*' -print); do hub release edit ${{ env.RELEASE_VERSION }} -m '' -a $f; done | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# region See: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio | ||
- name: Build Image | ||
run: | | ||
docker build -t $IMAGE_NAME . | ||
- name: Log In to Registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push Image | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
# Always tag latest when pushing a tag, as we don't expect to ever merge old tags | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && docker tag $IMAGE_NAME $IMAGE_ID:latest | ||
docker push $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:latest | ||
# endregion |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM dragas/thttpd | ||
|
||
COPY . ./ |
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
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
Oops, something went wrong.