diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml index 607dc9c61..dd1cc2028 100644 --- a/.github/workflows/push-main.yml +++ b/.github/workflows/push-main.yml @@ -29,10 +29,50 @@ jobs: CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} build-and-deploy: - uses: electron/website/.github/workflows/build-and-deploy.yml@main + name: Build and deploy the website + runs-on: ubuntu-latest permissions: actions: read - with: - branch: main - secrets: - SAS: ${{ secrets.SAS }} + steps: + - name: Set GIT_BRANCH + run: echo "GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV + - name: Print GIT_BRANCH + run: echo $GIT_BRANCH + - name: Print content + run: ls -ln + # This should be set up from earlier + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # tag: v4.0.4 + with: + node-version: 20 + - name: Install dependencies + uses: bahmutov/npm-install@dc9579d3dfb9c0e7a1f56c194eefcb8e2c9f0da5 # tag: v1.10.3 + - name: Lint + run: yarn lint + env: + CI: true + # FIXME: this is stalling + # - name: Download cache + # uses: nick-invision/retry@7152eba30c6575329ac0576536151aca5a72780e # tag: v3.0.0 + # with: + # timeout_seconds: 300 + # max_attempts: 3 + # retry_on: error + # command: ./scripts/bin/azcopy copy "https://electronwebsite.blob.core.windows.net/%24web/*?$SAS" "./build" --recursive + # env: + # SAS: ${{ secrets.SAS }} + - name: Add Docusaurus problem matcher + run: echo "::add-matcher::.github/problem-matchers/docusaurus.json" + - name: Build default locale site + run: yarn build + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish everything to Storage + uses: nick-invision/retry@7152eba30c6575329ac0576536151aca5a72780e # tag: v3.0.0 + with: + timeout_seconds: 300 + max_attempts: 3 + retry_on: error + command: ./scripts/bin/azcopy copy "./build/*" "https://electronwebsite.blob.core.windows.net/%24web/?$SAS" --recursive + env: + SAS: ${{ secrets.SAS }} diff --git a/scripts/build-as-doc-version.js b/scripts/build-as-doc-version.js deleted file mode 100644 index 9f0edee6b..000000000 --- a/scripts/build-as-doc-version.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This script takes a version passed as a parameter (i.e. v15-x-y), the - * current contents available under `/docs/latest`, and builds the project - * in such a way that the documentation is made available under - * `/docs/v15-x-y` or equivalent. - */ - -//@ts-check - -const fs = require('fs-extra'); -const globby = require('globby'); - -/** - * - * @param {string} version - */ -const moveDocs = async (version) => { - await fs.move('docs/latest', `docs/${version}`); - - const files = await globby([`docs/${version}/**/*.md`]); - - for (const file of files) { - const content = await fs.readFile(file, 'utf-8'); - let updatedContent = content.replace(/docs\/latest/gm, `docs/${version}`); - updatedContent = content.replace(/latest\//gm, `${version}/`); - await fs.writeFile(file, updatedContent, 'utf-8'); - } -}; - -/** - * - * @param {string} version - */ -const updateConfigFiles = async (version) => { - const configFiles = ['docusaurus.config.js', 'sidebars.js']; - for (const configFile of configFiles) { - const content = await fs.readFile(configFile, 'utf-8'); - const updatedContent = content.replace(/latest/g, version); - - await fs.writeFile(configFile, updatedContent, 'utf-8'); - } -}; - -/** - * - * @param {string} version - */ -const publishAsVersion = async (version) => { - await moveDocs(version); - await updateConfigFiles(version); -}; - -// When a file is run directly from Node.js, `require.main` is set to its module. -// That means that it is possible to determine whether a file has been run directly -// by testing `require.main === module`. -// https://nodejs.org/docs/latest/api/modules.html#modules_accessing_the_main_module -if (require.main === module) { - const version = process.argv[2]; - - if (!version) { - console.error('Please provide a version'); - } else if (!version.match(/v\d+/)) { - console.error('Version should be like "v12"'); - } else { - publishAsVersion(version); - } -} - -module.exports = { - publishAsVersion, -};