Skip to content

Commit

Permalink
ci(workflow/deploy-pages): refactor pages deployment into single work…
Browse files Browse the repository at this point in the history
…flow
  • Loading branch information
danielleroux committed Oct 20, 2022
1 parent 75fa565 commit 98d3232
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 159 deletions.
62 changes: 0 additions & 62 deletions .github/workflows/deploy-pages-dev.yml

This file was deleted.

52 changes: 0 additions & 52 deletions .github/workflows/deploy-pages-prod.yml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Deploy to GitHub Pages

on:
workflow_dispatch:
inputs:
confirm_deployment:
description: 'Please confirm deployment'
required: true
type: boolean
deployment:
description: 'Deployment instance'
required: true
default: 'dev'
type: choice
options:
- dev
- prod

permissions:
contents: write

jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
container:
image: node:16.16.0
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v3
- name: Check if deployment condition is fulfilled
if: ${{ startsWith(github.ref, 'refs/heads/release/docs/v') == false || github.event.inputs.confirm_deployment == false }}
run: |
echo "::error ::Be sure that the workflow run on release/docs/v* and you checked confirm"
exit -1
- name: Install rsync
run: |
apt-get update && apt-get install -y rsync
- uses: ./.github/workflows/actions/install
- uses: ./.github/workflows/actions/build
with:
filter: '\!documentation --filter \!@siemens/html-test-app'
- name: 'Download @siemens/ix-brand-theme'
run: |
rm .yarnrc
ROOT=$(pwd)
echo "@siemens:registry=https://code.siemens.com/api/v4/projects/249177/packages/npm/" >> .npmrc
echo "//code.siemens.com/api/v4/projects/249177/packages/npm/:_authToken=${{ secrets.READ_CSC_TOKEN }}" >> .npmrc
npm install @siemens/ix-brand-theme@^1.0.0 --no-save
rm .npmrc
cp -R ./node_modules/@siemens/ix-brand-theme ./packages/html-test-app/src/public/additional-theme
sed -i -e '/\"publishConfig\"/,/}/ d; /^$/d' ./packages/html-test-app/src/public/additional-theme/ix-brand-theme/package.json
rm ./packages/html-test-app/src/public/additional-theme/ix-brand-theme/package.json-e || true
- name: 'Build documentation for dev instance'
if: ${{ github.event.inputs.deployment == 'dev' }}
run: |
yarn workspace @siemens/html-test-app run build
BASE_URL=/ix/version-dev/ yarn workspace documentation run build
- name: 'Build documentation for prod instance'
if: ${{ github.event.inputs.deployment == 'prod' }}
run: |
yarn workspace @siemens/html-test-app run build
BASE_URL=/ix/ yarn workspace documentation run build
- name: Deploy production instance 🚀
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.event.inputs.deployment == 'prod' }}
with:
folder: ./packages/documentation/build
clean-exclude: version-*

- name: Deploy dev instance 🚀
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.event.inputs.deployment == 'dev' }}
with:
folder: ./packages/documentation/build
target-folder: version-dev
clean-exclude: version-*
9 changes: 5 additions & 4 deletions packages/documentation/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ const config = {
position: 'left',
label: 'Siemens iX',
},
{
type: 'docsVersionDropdown',
position: 'right',
},
// Remove docs version until library needs to publish an major release
// {
// type: 'docsVersionDropdown',
// position: 'right',
// },
],
},
footer: {
Expand Down
34 changes: 0 additions & 34 deletions scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,40 +277,6 @@ sidebar_position: 100
});
}

async function createDocumentationVersion(tasks, version) {
if (version.includes('-beta.')) {
const result = await inquirer.prompt([
{
type: 'confirm',
name: 'confirm',
message: () => {
return `${version} is a beta version. Do you want to generate documentation for beta release?`;
},
},
]);

if (!result.confirm) {
console.log(red('Skip documentation generation!'));
return;
}
}

tasks.push({
title: 'Generate new documentation version',
task: async () => {
await execa('yarn', [
'run',
'generate-documentation-version',
'--',
'--',
version,
]);
},
});

return Promise.resolve();
}

function getVersionCommitMessage(version) {
return `chore: bump ix version to ${version}`;
}
Expand Down
8 changes: 1 addition & 7 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const {
generateChangelog,
getVersionCommitMessage,
readPackage,
createDocumentationVersion,
} = require('./common');
const Listr = require('listr');
const execa = require('execa');
Expand All @@ -33,20 +32,19 @@ const skipGitCheck = params.some((p) => p.includes('--skip-git-check'));
'./packages/react-test-app',
'./packages/aggrid',
'./packages/echarts',
'./packages/html-test-app',
'./packages/documentation',
];

const answer = await askVersion();
const { confirm } = answer;

let version;
let isPatch = false;

if (typeof answer.version === 'string') {
version = answer.version;
} else {
version = answer.version.version;
isPatch = answer.version.type === 'patch';
}

if (!confirm) {
Expand Down Expand Up @@ -174,10 +172,6 @@ const skipGitCheck = params.some((p) => p.includes('--skip-git-check'));

generateChangelog(tasks);

if (!isPatch) {
await createDocumentationVersion(tasks, version);
}

tasks.push({
title: 'Build Documentation 📚',
task: () => {
Expand Down

0 comments on commit 98d3232

Please sign in to comment.