Skip to content

Commit

Permalink
Created GitHub Actions
Browse files Browse the repository at this point in the history
- Can manually deploy site or automatically deploy on push to main branch
  • Loading branch information
Kaister300 committed Feb 5, 2024
1 parent 92c3452 commit c89e0e0
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 2 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/deploy-page.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Deploy Webpage to Cloudflare Pages"
on:
workflow_call:
inputs:
environment:
required: true
type: string

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"

- name: Install dependencies
run: |
npm install
pip install -r project/requirements.txt
- name: Create .env file
run: |
cat <<EOF > .env
WEBSITE=${{ vars.CLOUDFLARE_PAGE_URL }}
GOOGLE_SEARCHCONSOLE_AUTH=${{ secrets.GOOGLE_SEARCHCONSOLE_AUTH }}
BING_WEBMASTER_AUTH=${{ secrets.BING_WEBMASTER_AUTH }}
EOF
- name: Build static files
run: python3 project/make.py

- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: "project/output"
command: pages deploy --project-name=${{inputs.environment}}
20 changes: 20 additions & 0 deletions .github/workflows/on-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Manual build"
on:
workflow_dispatch:
inputs:
environment:
description: "Choose an environment to deploy to:"
type: choice
options:
- "prod"
- "staging"
- "dev"
default: "dev"

jobs:
deploy-page:
name: Deploy page
uses: ./.github/workflows/deploy-page.yaml
secrets: inherit
with:
environment: ${{ github.event.inputs.environment }}
13 changes: 13 additions & 0 deletions .github/workflows/on-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Deploy on push"
on:
push:
branches:
- main

jobs:
deploy-page:
name: Deploy page
uses: ./.github/workflows/deploy-page.yaml
secrets: inherit
with:
environment: "prod"
4 changes: 2 additions & 2 deletions project/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def build_headers(dest_dir, website):
file.write(f"{website}BingSiteAuth.xml\n")
file.write(robot_tag)

if google_auth := os.getenv("GOOGLE_SEACHCONSOLE_AUTH"):
if google_auth := os.getenv("GOOGLE_SEARCHCONSOLE_AUTH"):
file.write(f"{website}{google_auth}\n")
file.write(robot_tag)

Expand Down Expand Up @@ -174,7 +174,7 @@ def build_website():
print_terminal("Skipped _headers and Sitemap Files", TerminalColours.NO)

# Adds Google and Bing Auth Files
google_auth = os.getenv("GOOGLE_SEACHCONSOLE_AUTH")
google_auth = os.getenv("GOOGLE_SEARCHCONSOLE_AUTH")
if google_auth:
build_google_auth(build_dir, google_auth)
print_terminal("Google Auth File Built", TerminalColours.OK)
Expand Down

0 comments on commit c89e0e0

Please sign in to comment.