Skip to content

Commit

Permalink
Setup new deployment and pr preview deployments (#21)
Browse files Browse the repository at this point in the history
# Description

As a non-technical (or technical) reviewer of site changes, I want to
see the site running so that I can see how it actually works.

- Closes #20 

## Screenshot(s)



## Type of change

- [x] CI/Dependencies/etc...

# How to Test?

Please describe how to test that you ran to verify your changes. Provide
instructions so we can reproduce. Please also
list any relevant details for your test configuration

1. Check the Actions results
2. See that the site is still live!

- Deployment of root:
https://github.com/frequency-chain/frequency-xyz/actions/runs/11145981761
- PR preview deployment:
https://github.com/frequency-chain/frequency-xyz/actions/runs/11146209046
- PR Preview Removal Test coming once this PR merges: ...

# Checklist:

- [x] I have performed a self-review of my code
- [x] I have commented my code & PR, particularly in hard-to-understand
areas
  • Loading branch information
wilwade authored Oct 2, 2024
1 parent 54bede7 commit 7a14996
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 36 deletions.
31 changes: 14 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Deploy to GitHub Pages

# Preview PRs via actions/deploy-pages is not available so using JamesIves/github-pages-deploy-action
# https://github.com/orgs/community/discussions/7730

on:
push:
tags:
Expand All @@ -12,8 +15,7 @@ on:

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

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
Expand Down Expand Up @@ -50,20 +52,15 @@ jobs:
npm run build
touch build/.nojekyll
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@881db5376404c5c8d621010bcbec0310b58d5e29
with:
path: ./build

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
folder: build
clean: true
clean-exclude: |
_pr/**
commit-message: Deploy to GitHub Pages

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Update Job Summary
run: |
echo "🚀 [https://www.frequency.xyz](https://www.frequency.xyz)" >> $GITHUB_STEP_SUMMARY
42 changes: 42 additions & 0 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Remove PR Deploy Preview

on:
pull_request:
types: [closed]

permissions:
contents: 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: 'deploy-pages'
cancel-in-progress: false

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove PR preview
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
if [ -d "_pr/$PR_NUMBER" ]; then
git config user.name github-actions
git config user.email github-actions@github.com
git rm -rf "_pr/$PR_NUMBER"
git commit -m "Remove PR preview for #$PR_NUMBER"
git push
else
echo "Preview folder for PR #$PR_NUMBER does not exist. Skipping cleanup."
fi
- name: Update Job Summary
run: |
echo "## Cleanup Summary" >> $GITHUB_STEP_SUMMARY
echo "🧹 Removed preview for PR #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY
94 changes: 94 additions & 0 deletions .github/workflows/pr-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: PR Deploy Preview

# Preview PRs via actions/deploy-pages is not available so using JamesIves/github-pages-deploy-action
# https://github.com/orgs/community/discussions/7730

on:
pull_request:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pull-requests: 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: 'deploy-pages'
cancel-in-progress: false

jobs:
deploy-preview:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Install dependencies
run: npm install

- name: Build
env:
# Deploying to a root domain
BASE_PATH: /_pr/${{ github.event.pull_request.number }}
run: |
npm run build
touch build/.nojekyll
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@881db5376404c5c8d621010bcbec0310b58d5e29
with:
folder: build
target-folder: _pr/${{ github.event.pull_request.number }}

- name: Update Job Summary
run: |
echo "## Preview URL" >> $GITHUB_STEP_SUMMARY
echo "🚀 [https://www.frequency.xyz/_pr/${{ github.event.pull_request.number }}](https://www.frequency.xyz/_pr/${{ github.event.pull_request.number }})" >> $GITHUB_STEP_SUMMARY
- name: Comment PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const prNumber = context.issue.number;
const sha = context.sha;
const deploymentUrl = `https://www.frequency.xyz/_pr/${prNumber}/`;
const commitUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${sha}`;
const body = `🚀 Preview deployment for this PR is going up! Remember you might need to hard refresh to get the new content.\n\nPreview URL: [${deploymentUrl}](${deploymentUrl})\nCommit: [${sha.substr(0, 7)}](${commitUrl})`;
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existingComment = comments.data.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('Preview deployment for this PR is ready!')
);
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: body,
});
}
6 changes: 5 additions & 1 deletion src/components/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<script type="ts">
import { base } from '$app/paths';
</script>

<footer class="freq-container flex h-[50px] items-center justify-end gap-3 text-xs font-semibold">
<div>© {new Date().getFullYear()} Frequency Network Foundation</div>
<span class="h-4 w-[2px] bg-black" />
<a href="/privacy">Privacy Policy</a>
<a href="{base}/privacy">Privacy Policy</a>
<span class="h-4 w-[2px] bg-black" />
<div class="whitespace-nowrap">All Rights Reserved</div>
</footer>
43 changes: 25 additions & 18 deletions src/routes/privacy/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<script type="ts">
import { base } from '$app/paths';
</script>

<div class="mx-auto flex-grow justify-center px-4 sm:px-6 lg:px-8">
<h3 class="title-75">Privacy Policy</h3>
<div class="privacy max-lg">
Expand All @@ -16,20 +20,23 @@
located at https://claimfrequency.xyz.
</p>
<ol>
<li><a href="/privacy/#notice_regarding_use_of_the_blockchain">NOTICE REGARDING USE OF THE BLOCKCHAIN</a></li>
<li><a href="/privacy/#updates_to_this_privacy_notice">UPDATES TO THIS PRIVACY NOTICE</a></li>
<li><a href="/privacy/#personal_information_we_collect">PERSONAL INFORMATION WE COLLECT</a></li>
<li><a href="/privacy/#how_we_use_personal_information">HOW WE USE PERSONAL INFORMATION</a></li>
<li><a href="/privacy/#how_we_disclose_personal_information">HOW WE DISCLOSE PERSONAL INFORMATION</a></li>
<li><a href="/privacy/#your_privacy_choices_and_rights">YOUR PRIVACY CHOICES AND RIGHTS</a></li>
<li>
<a href="/privacy/#international_transfers_of_personal">INTERNATIONAL TRANSFERS OF PERSONAL INFORMATI</a>ON
<a href="{base}/privacy/#notice_regarding_use_of_the_blockchain">NOTICE REGARDING USE OF THE BLOCKCHAIN</a>
</li>
<li><a href="{base}/privacy/#updates_to_this_privacy_notice">UPDATES TO THIS PRIVACY NOTICE</a></li>
<li><a href="{base}/privacy/#personal_information_we_collect">PERSONAL INFORMATION WE COLLECT</a></li>
<li><a href="{base}/privacy/#how_we_use_personal_information">HOW WE USE PERSONAL INFORMATION</a></li>
<li><a href="{base}/privacy/#how_we_disclose_personal_information">HOW WE DISCLOSE PERSONAL INFORMATION</a></li>
<li><a href="{base}/privacy/#your_privacy_choices_and_rights">YOUR PRIVACY CHOICES AND RIGHTS</a></li>
<li>
<a href="{base}/privacy/#international_transfers_of_personal">INTERNATIONAL TRANSFERS OF PERSONAL INFORMATI</a
>ON
</li>
<li><a href="/privacy/#retention_of_personal_information">RETENTION OF PERSONAL INFORMATION</a></li>
<li><a href="/privacy/#supplemental_notice_for_eu_gdpr">SUPPLEMENTAL NOTICE FOR EU GDPR</a></li>
<li><a href="/privacy/#childrens_information">CHILDREN’S INFORMATION</a></li>
<li><a href="/privacy/#third_party_websites_applications">THIRD-PARTY WEBSITES/APPLICATIONS</a></li>
<li><a href="/privacy/#contact_us">CONTACT US</a></li>
<li><a href="{base}/privacy/#retention_of_personal_information">RETENTION OF PERSONAL INFORMATION</a></li>
<li><a href="{base}/privacy/#supplemental_notice_for_eu_gdpr">SUPPLEMENTAL NOTICE FOR EU GDPR</a></li>
<li><a href="{base}/privacy/#childrens_information">CHILDREN’S INFORMATION</a></li>
<li><a href="{base}/privacy/#third_party_websites_applications">THIRD-PARTY WEBSITES/APPLICATIONS</a></li>
<li><a href="{base}/privacy/#contact_us">CONTACT US</a></li>
</ol>
<h4 id="notice_regarding_use_of_the_blockchain">1. NOTICE REGARDING USE OF THE BLOCKCHAIN</h4>
<p>
Expand Down Expand Up @@ -111,7 +118,7 @@
have been opened, acted on, or forwarded.
<p>
<em
>See “<a href="/privacy/#rights">Your Privacy Choices and Rights</a>” below to understand your choices
>See “<a href="{base}/privacy/#rights">Your Privacy Choices and Rights</a>” below to understand your choices
regarding these Technologies.</em
>
</p>
Expand Down Expand Up @@ -179,7 +186,7 @@
</p>
<p>
If you have any questions about our marketing practices, you may contact us at any time as set forth in “<a
href="/privacy/#contact_us">Contact Us</a
href="{base}/privacy/#contact_us">Contact Us</a
>” below.
</p>
<h5>D. With Your Consent</h5>
Expand Down Expand Up @@ -372,10 +379,10 @@
</p>
<p>
If you are a parent or guardian and believe your child has uploaded personal information to our site without your
consent, you may contact us as described in “<a href="/privacy/#contact_us">Contact Us</a>” below. If we become
aware that a child has provided us with personal information in violation of applicable law, we will delete any
personal information we have collected, unless we have a legal obligation to keep it, and terminate the child’s
account, if applicable.
consent, you may contact us as described in “<a href="{base}/privacy/#contact_us">Contact Us</a>” below. If we
become aware that a child has provided us with personal information in violation of applicable law, we will delete
any personal information we have collected, unless we have a legal obligation to keep it, and terminate the
child’s account, if applicable.
</p>
<h4 id="third_party_websites_applications">11. THIRD-PARTY WEBSITES/APPLICATIONS</h4>
<p>
Expand Down
3 changes: 3 additions & 0 deletions static/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User-agent: *
Disallow:
Disallow: /_pr/

0 comments on commit 7a14996

Please sign in to comment.