Skip to content

Commit

Permalink
Release to GitHub Pages (#7)
Browse files Browse the repository at this point in the history
* Prepare for release

* Update badge

* Fix Permissions-Policy header when run on GitHub Pages
  • Loading branch information
javiertuya authored Feb 13, 2024
1 parent 82c65e3 commit 6403526
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 14 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Deploy app when is tagged on main branch (a release is published)
name: release

on:
release:
types: [created]

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

# Allow one concurrent deployment, but do not cancel in-progress runs
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4

- name: Prepare release
working-directory: dashgit-web
run: |
chmod u+rx ./prepare-release.sh
./prepare-release.sh "$GITHUB_REF_NAME"
- name: Upload artifact to deploy
uses: actions/[email protected]
with:
path: 'dashgit-web/dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Status](https://github.com/javiertuya/dashgit/actions/workflows/test.yml/badge.svg)](https://github.com/javiertuya/dashgit/actions)
[![Run DashGit](https://img.shields.io/badge/%20-Run_DashGit-orange)](https://javiertuya.github.io/dashgit)

# DashGit - A Dashboard for GitHub and GitLab repos

This dashboard provides a consolidated view of your latest work items
Expand Down
33 changes: 20 additions & 13 deletions dashgit-web/app/IndexController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ import { configController } from "./ConfigController.js"

/**
* Manages the top level elements visibility and actions (header and tabs).
* Enters one of two modes depending on the token encription configuration
* Enters one of two modes depending on the token encription configuration.
*
* Note: The index.html cannot import this module with src, on chromium causes this error:
* Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.
* Solution is to define an inline module in index.html that initializes jquery and imports this controller
*/
$(document).ready(async function () {
config.appVersion = $("#appVersion").text();
console.log(`Loading, version ${config.appVersion}`)
config.load();
if (config.data.encrypted) {
indexController.loginMode();
} else {
indexController.workMode();
indexController.render();
}
$('[data-toggle="tooltip"]').tooltip({ trigger: "hover", delay: 600 });
});

//In login mode, enter and validate password
$(document).on('click', '#inputPasswordButton', function (e) {
Expand Down Expand Up @@ -68,6 +60,21 @@ $(document).on('click', '.accordion-button', function () {
});

const indexController = {

// Initial configuration to be run by jquery on document ready
load: function() {
config.appVersion = $("#appVersion").text();
config.load();
$("#appVersion").text(config.appVersion);
if (config.data.encrypted) {
indexController.loginMode();
} else {
indexController.workMode();
indexController.render();
}
$('[data-toggle="tooltip"]').tooltip({trigger:"hover", delay:600});
},

//Rendering depends on the selected tab, calls the appropriate controller to update the UI
render: function () {
wiView.resetAlerts();
Expand Down
7 changes: 6 additions & 1 deletion dashgit-web/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
}
}
</script>
<script type="module" src="./indexController.js"></script>
<script type="module">
import { indexController } from "./IndexController.js"
$(document).ready(async function () {
indexController.load();
});
</script>
</head>

<style>
Expand Down
22 changes: 22 additions & 0 deletions dashgit-web/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Prepares the distribution for release and set version number

# Ensure this script is running in his folder
SCRIPT_DIR=$(readlink -f $0 | xargs dirname)
echo "run command at directory: $SCRIPT_DIR"
cd $SCRIPT_DIR

# Ensure version to set is passed as parameter
VERSION=$1
if test -z "$VERSION"; then
echo "Required parameter: version to set"
exit 1
fi
echo "Set version to $VERSION"

# Copy app files to dist and set version numbers (in index.html and *.js to prevent cache problems)
rm -rf ./dist/
cp -rf ./app ./dist
find ./dist/*.js -type f -exec sed -i "s/.js\"/.js\?v=${VERSION}\"/g" {} \;
sed -i "s/IndexController.js/IndexController.js?v=${VERSION}/g" dist/index.html
sed -i "s/v0.0.0-local/${VERSION}/g" dist/index.html

0 comments on commit 6403526

Please sign in to comment.