Skip to content

Commit

Permalink
ci: 👷 display URL for github action deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
jojobyte committed Mar 23, 2024
1 parent 5e9f05d commit f431f28
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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([
'<a target="_blank" href="https://github.com/dashhive/wallet-ui">Source Code</a>',
`<a target="_blank" href="https://github.com/dashhive/wallet-ui/tree/${GITHUB_REF_NAME}">Source Code</a> for <br/><output>${GITHUB_REF_NAME}</output>`,
])
}

const walk = async (
dirPath,
filterFiles = f => f
Expand Down Expand Up @@ -54,7 +67,8 @@ const fixOrCopy = async (
[
'../public/',
'../public/'
]
],
...footerReplacer,
],
}
) => {
Expand All @@ -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');
Expand Down Expand Up @@ -127,6 +141,7 @@ try {
'../public/',
'./public/'
],
...footerReplacer,
],
js: [
[
Expand All @@ -141,6 +156,7 @@ try {
'/src/manifest.webmanifest',
'/manifest.webmanifest',
],
...footerReplacer,
],
json: [
[
Expand All @@ -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);
}
18 changes: 16 additions & 2 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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*'
Expand Down
7 changes: 6 additions & 1 deletion src/styles/code.css
Original file line number Diff line number Diff line change
@@ -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; */
Expand Down

0 comments on commit f431f28

Please sign in to comment.