Skip to content

Commit

Permalink
Remove separate lint JSON action, add sha hash key idea to deployed J…
Browse files Browse the repository at this point in the history
…SON automagically
  • Loading branch information
nythepegasus committed Nov 13, 2024
1 parent b3a6034 commit c75a6c7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 61 deletions.
1 change: 1 addition & 0 deletions .github/apt-packs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coreutils jq
36 changes: 0 additions & 36 deletions .github/workflows/lint-json.yml

This file was deleted.

47 changes: 22 additions & 25 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,58 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

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

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache APT packages
uses: actions/cache@v4
with:
path: /var/cache/apt/archives
key: ${{ runner.os }}-apt-cache-${{ hashFiles('.github/apt-packs.txt') }}
restore-keys: |
${{ runner.os }}-apt-cache-
- name: Update APT cache
run: sudo apt-get update
- name: Install jq
run: sudo apt-get install -y jq
- name: Install dependencies
run: sudo apt-get install -y coreutils jq
- name: Checkout
uses: actions/checkout@v4
- name: Lint servers.json
run: |
if ! jq empty servers.json; then
if jq empty servers.json > /dev/null 2>&1; then
echo "servers.json is valid"
else
echo "Invalid JSON file detected in servers.json"
exit 1
else
echo "servers.json is valid"
fi
- name: Cache APT packages
uses: actions/cache@v4
with:
path: /var/cache/apt/archives
key: ${{ runner.os }}-apt-cache
restore-keys: |
${{ runner.os }}-apt-cache
- name: Setup Pages
uses: actions/configure-pages@v5
uses: actions/configure-pages@v4
- name: Generate hash file
run: |
sha256sum servers.json | cut -d ' ' -f1 | cut -c1-8 > servers.json.hash
- name: Add hash URL to servers.json
run: |
jq --arg url "https://$(cat CNAME)/servers.json.hash" '. + {"cache": $url}' servers.json > servers.json
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4

0 comments on commit c75a6c7

Please sign in to comment.