From f431f28914fe900e9a13f38f39249f73dc5c10fb Mon Sep 17 00:00:00 2001
From: jojobyte <184880+jojobyte@users.noreply.github.com>
Date: Sat, 23 Mar 2024 05:30:09 -0600
Subject: [PATCH] ci: :construction_worker: display URL for github action
deployments
---
.github/workflows/deploy.js | 31 +++++++++++++++++++++++++------
.github/workflows/static.yml | 18 ++++++++++++++++--
src/styles/code.css | 7 ++++++-
3 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/deploy.js b/.github/workflows/deploy.js
index e6bc699..d52d543 100644
--- a/.github/workflows/deploy.js
+++ b/.github/workflows/deploy.js
@@ -4,7 +4,11 @@ process.removeAllListeners('warning');
process.on('SIGTERM', () => process.exit());
process.on('SIGINT', () => process.exit());
-const { BASE_HREF = '' } = process.env
+const {
+ BASE_HREF = '',
+ GITHUB_REF_NAME = '',
+ PAGE_URL = '',
+} = process.env
import {
readFile, writeFile, readdir,
@@ -17,6 +21,15 @@ const PUB = 'public/'
const DIST = './dist/'
const FAV = 'favicon.png'
+let footerReplacer = []
+
+if (GITHUB_REF_NAME && !['master','main'].includes(GITHUB_REF_NAME)) {
+ footerReplacer.push([
+ 'Source Code',
+ `Source Code for
`,
+ ])
+}
+
const walk = async (
dirPath,
filterFiles = f => f
@@ -54,7 +67,8 @@ const fixOrCopy = async (
[
'../public/',
'../public/'
- ]
+ ],
+ ...footerReplacer,
],
}
) => {
@@ -63,7 +77,7 @@ const fixOrCopy = async (
await cp(sourceFile, targetFile, { recursive: true, });
if (exts.includes(ext)) {
- console.log('fix', sourceFile, targetFile, ext)
+ // console.log('fix', sourceFile, targetFile, ext)
// console.log('fixOrCopy replacer', replacer[ext])
let data = await readFile(sourceFile, 'utf-8');
@@ -127,6 +141,7 @@ try {
'../public/',
'./public/'
],
+ ...footerReplacer,
],
js: [
[
@@ -141,6 +156,7 @@ try {
'/src/manifest.webmanifest',
'/manifest.webmanifest',
],
+ ...footerReplacer,
],
json: [
[
@@ -158,10 +174,13 @@ try {
})
+ // console.log(
+ // 'prepare files for deployment',
+ // allFiles
+ // );
console.log(
- 'prepare files for deployment',
- allFiles
+ PAGE_URL,
);
} catch (err) {
- console.error(err);
+ // console.error(err);
}
diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index 31e8cec..a050922 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -16,7 +16,9 @@ jobs:
# branch: ${{ steps.clean_branch.outputs.branch }}
environment:
name: wallet
- url: ${{ vars.WEBSITE }}
+ # url: ${{ vars.WEBSITE }}
+ # url: ${{ steps.clean_branch.outputs.page_url }}
+ url: ${{ steps.run_deploy.outputs.deploy_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -28,16 +30,28 @@ jobs:
node-version: 20
cache: 'npm'
- run: npm ci
- - run: npm run deploy
- name: Get clean branch name
id: clean_branch
env:
REPLACE_SLASH: "/"
WITH_DASH: "-"
+ # echo "page_url=https://$BRANCH.wallet.dashincubator.dev/" >> "$GITHUB_OUTPUT"
run: |
export BRANCH=${GITHUB_REF_NAME//$REPLACE_SLASH/$WITH_DASH}
+ export PAGE_URL=https://$BRANCH.wallet.dashincubator.dev/
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
+ echo "name=page_url::$PAGE_URL" >> $GITHUB_OUTPUT
+ - name: Run deploy.js
+ id: run_deploy
+ env:
+ PAGE_URL: ${{ steps.clean_branch.outputs.page_url }}
+ GITHUB_REF_NAME: ${{ github.ref_name }}
+ GITHUB_OUTPUT: $GITHUB_OUTPUT
+ run: |
+ DEPLOY_URL=$(((node .github/workflows/deploy.js) 2>&1) || true)
+ echo "name=deploy_url::$DEPLOY_URL" >> $GITHUB_OUTPUT
- name: Deploy via rsync
+ id: deployment
uses: bnnanet/github-actions-rsync@master
with:
RSYNC_OPTIONS: -avzr --delete --exclude '.git*'
diff --git a/src/styles/code.css b/src/styles/code.css
index a988f26..0f81373 100644
--- a/src/styles/code.css
+++ b/src/styles/code.css
@@ -1,7 +1,12 @@
-pre {
+pre, output {
background-color: var(--c);
font-family: var(--fm);
font-size: 14px;
+}
+output {
+ padding: .25rem;
+}
+pre {
padding: 1rem;
max-width: 100%;
/* overflow: auto; */