Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set base urls dynamically #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,23 @@ jobs:
uses: actions/[email protected]
with:
node-version: 18.x
- name: Set Github Page Url Variable
id: get_page_url
run: |
if [ -f "CNAME" ]; then
DOMAIN=$(cat CNAME)
echo "Custom domain found: $DOMAIN"
else
DOMAIN="${{ github.repository_owner }}.github.io"
echo "No custom domain found. Using default domain: $DOMAIN"
fi
REPOSITORY_NAME="${{ github.event.repository.name }}"
FULL_URL="$DOMAIN/$REPOSITORY_NAME"
echo "::set-output name=url::$FULL_URL"
- name: Build index
run: node index.js
env:
GITHUB_PAGES_URL: ${{ steps.get_page_url.outputs.url }}
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
3 changes: 0 additions & 3 deletions config.json

This file was deleted.

25 changes: 13 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs')
const { config } = require('process')
const configFile = require('./config.json')
const githubPagesUrl = `https://${process.env.GITHUB_PAGES_URL}`
const localhost = "http://localhost:3000"


// list all directories in the directory servapps and compile them in servapps.json

Expand All @@ -17,24 +18,24 @@ for (const file of servapps) {
// list all screenshots in the directory servapps/${file}/screenshots
const screenshots = fs.readdirSync(`./servapps/${file}/screenshots`)
for (const screenshot of screenshots) {
servapp.screenshots.push(`https://azukaar.github.io/cosmos-servapps-official/servapps/${file}/screenshots/${screenshot}`)
servapp.screenshots.push(`${githubPagesUrl}/servapps/${file}/screenshots/${screenshot}`)
}

if(fs.existsSync(`./servapps/${file}/artefacts`)) {
const artefacts = fs.readdirSync(`./servapps/${file}/artefacts`)
for(const artefact of artefacts) {
servapp.artefacts[artefact] = (`https://azukaar.github.io/cosmos-servapps-official/servapps/${file}/artefacts/${artefact}`)
servapp.artefacts[artefact] = (`${githubPagesUrl}/servapps/${file}/artefacts/${artefact}`)
}
}

servapp.icon = `https://azukaar.github.io/cosmos-servapps-official/servapps/${file}/icon.png`
servapp.icon = `${githubPagesUrl}/servapps/${file}/icon.png`
//Common Format,used by most
const YMLComposeSource = `https://azukaar.github.io/cosmos-servapps-official/servapps/${file}/docker-compose.yml`;
const YMLComposeSource = `${githubPagesUrl}/servapps/${file}/docker-compose.yml`;
if(fs.existsSync(`./servapps/${file}/docker-compose.yml`)) {
servapp.compose = YMLComposeSource;
}
//Cosmos Legacy Format
const CosmosComposeSource = `https://azukaar.github.io/cosmos-servapps-official/servapps/${file}/cosmos-compose.json`;
const CosmosComposeSource = `${githubPagesUrl}/servapps/${file}/cosmos-compose.json`;
if(fs.existsSync(`./servapps/${file}/cosmos-compose.json`)) {
servapp.compose = CosmosComposeSource;
}
Expand All @@ -47,7 +48,7 @@ const _sc = ["Jellyfin", "Home Assistant", "Nextcloud"];
const showcases = servappsJSON.filter((app) => _sc.includes(app.name));

let apps = {
"source": configFile.url,
"source": `${githubPagesUrl}/servapps.json`,
"showcase": showcases,
"all": servappsJSON
}
Expand All @@ -56,13 +57,13 @@ fs.writeFileSync('./servapps.json', JSON.stringify(servappsJSON, null, 2))
fs.writeFileSync('./index.json', JSON.stringify(apps, null, 2))

for (const servapp of servappsJSON) {
servapp.compose = `http://localhost:3000/servapps/${servapp.id}/cosmos-compose.json`
servapp.icon = `http://localhost:3000/servapps/${servapp.id}/icon.png`
servapp.compose = `${localhost}/servapps/${servapp.id}/cosmos-compose.json`
servapp.icon = `${localhost}/servapps/${servapp.id}/icon.png`
for (let i = 0; i < servapp.screenshots.length; i++) {
servapp.screenshots[i] = servapp.screenshots[i].replace('https://azukaar.github.io/cosmos-servapps-official', 'http://localhost:3000')
servapp.screenshots[i] = servapp.screenshots[i].replace('${githubPagesUrl}', '${localhost}')
}
for (const artefact in servapp.artefacts) {
servapp.artefacts[artefact] = servapp.artefacts[artefact].replace('https://azukaar.github.io/cosmos-servapps-official', 'http://localhost:3000')
servapp.artefacts[artefact] = servapp.artefacts[artefact].replace('${githubPagesUrl}', '${localhost}')
}
}

Expand Down