diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 76dee46d9..ca7e6512d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,17 +1,19 @@ --- name: Deployment on: + push: + branches: + - main workflow_dispatch: inputs: env: description: "Select environment to deploy to" type: choice required: true - default: "stage" + default: "prod" options: - - stage - - prod - - stage & prod + - "prod" + - "stage & prod" baseSha: description: "Use base SHA commit to deploy from (empty string defaults to last commit before HEAD)" type: string @@ -26,14 +28,6 @@ jobs: name: Deployment uses: AdobeDocs/adp-devsite-workflow/.github/workflows/deploy.yml@main with: - env: ${{ inputs.env }} - baseSha: ${{ inputs.baseSha }} - deployAll: ${{ inputs.deployAll }} - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Lint - run: npx --yes github:AdobeDocs/adp-devsite-utils runLint -v + env: ${{ inputs.env || 'prod' }} + baseSha: ${{ inputs.baseSha || '' }} + deployAll: ${{ inputs.deployAll || false }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 18f1e49d3..863d6d24e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,17 +1,17 @@ --- - name: Lint - on: - pull_request: - branches: [main] - paths: - - 'src/pages/**' - - jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Lint - run: npx --yes github:AdobeDocs/adp-devsite-utils runLint -v \ No newline at end of file +name: Lint +on: + pull_request: + branches: [main] + paths: + - 'src/pages/**' + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Lint + run: npx --yes github:AdobeDocs/adp-devsite-utils runLint -v diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml new file mode 100644 index 000000000..c96a42de7 --- /dev/null +++ b/.github/workflows/stage.yml @@ -0,0 +1,22 @@ +--- +name: Staging +on: + workflow_dispatch: + inputs: + baseSha: + description: "Use base SHA commit to deploy from (empty string defaults to last commit before HEAD)" + type: string + required: false + default: "" + deployAll: + description: "Force deploy all files" + type: boolean + default: false +jobs: + deployment: + name: Deployment + uses: AdobeDocs/adp-devsite-workflow/.github/workflows/deploy.yml@main + with: + env: stage + baseSha: ${{ inputs.baseSha }} + deployAll: ${{ inputs.deployAll }} diff --git a/.gitignore b/.gitignore index 7b703cdee..b57f564b9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ # npm yarn node_modules -package.lock +package-lock.json yarn-error.log .pnp.* .yarn/* @@ -43,4 +43,7 @@ local-test.yml # yalc .yalc -yalc.lock \ No newline at end of file +yalc.lock + +# json files +adp-site-metadata.json diff --git a/README.md b/README.md index 978030fb1..76b7e7c56 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Documentation -Please see the [centralized README](https://github.com/AdobeDocs/adp-devsite-utils/blob/main/README.md). +Please see the [ADP Developer Site Documentation](https://developer-stage.adobe.com/dev-docs-reference/). diff --git a/dev.mjs b/dev.mjs index 412e84de7..55efb9f27 100644 --- a/dev.mjs +++ b/dev.mjs @@ -5,12 +5,22 @@ import express from 'express'; import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; +import { execSync } from 'child_process'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const PORT = process.env.DEV_PORT || 3003; -// TODO: ensure `DOCS_DIRECTORY` starts with `/` +const getCurrentBranch = () => { + try { + return execSync('git branch --show-current', { encoding: 'utf8' }).trim(); + } catch (error) { + console.warn('Could not determine git branch, defaulting to "main"'); + return 'main'; + } +}; + +const currentBranch = getCurrentBranch(); const DOCS_DIRECTORY = process.env.DIRECTORY || './src/pages'; const app = express(); @@ -19,10 +29,11 @@ app.use( express.static(path.resolve(__dirname, `./${DOCS_DIRECTORY}`), { setHeaders: (res) => { res.setHeader('last-modified', new Date().toGMTString()); + res.setHeader('local-branch-name', currentBranch); }, }), ); app.listen(PORT, () => { console.debug(`Docs dev server is running on port ${PORT}`); -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index e2dc9ccc9..6a92eecc9 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "redirectCheck:stage": "npx --yes github:AdobeDocs/adp-devsite-utils redirectChecker stage --verbose", "redirectCheck:prod": "npx --yes github:AdobeDocs/adp-devsite-utils redirectChecker prod --verbose" }, - "packageManager": "yarn@3.2.1", "devDependencies": { "express": "5.1.0" }