diff --git a/.github/workflows/fg-sync-repos.yml b/.github/workflows/fg-sync-repos.yml new file mode 100644 index 0000000..afd55ab --- /dev/null +++ b/.github/workflows/fg-sync-repos.yml @@ -0,0 +1,67 @@ +name: Floodgate Repo Sync + +on: + workflow_dispatch: + inputs: + syncBranch: + description: 'Branch to sync' + required: true + default: 'stage' + type: choice + options: + - 'stage' + - 'main' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Generate a token + id: generate_token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.FG_SYNC_APP_ID }} + private-key: ${{ secrets.FG_SYNC_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: "bacom-blog-pink" + + - name: Checkout Repo + uses: actions/checkout@v3 + with: + ref: ${{ inputs.syncBranch }} + + - name: Clone Floodgate Repository and Checkout Selected Branch + run: | + git clone https://github.com/adobecom/bacom-blog-pink.git ../bacom-blog-pink + cd ../bacom-blog-pink + git checkout $FG_SYNC_BRANCH + echo "bacom-blog-pink branch" + git branch + cd ../bacom-blog + echo "bacom-blog branch" + git branch + env: + FG_SYNC_BRANCH: ${{ inputs.syncBranch }} + + - name: Overwrite floodgate repo files with latest from source repo + run: | + rsync -av --exclude='fstab.yaml' --exclude='.github' --exclude='.kodiak' --exclude='.git' --exclude='.idea' --exclude='.husky' --exclude='.vscode' --exclude='tools/sidekick/config.json' ./ ../bacom-blog-pink/ + + - name: Commit and Push Changes to Floodgate Repository + run: | + cd ../bacom-blog-pink + echo "bacom-blog-pink branch" + git branch + git config user.email "$FG_SYNC_BOT_EMAIL" + git config user.name "$FG_SYNC_BOT_NAME" + git status + git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-blog-pink.git + git remote -v + git add . + git commit -m "Syncing bacom-blog to bacom-blog-pink" + git push origin $FG_SYNC_BRANCH --force + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + FG_SYNC_BOT_EMAIL: ${{ secrets.FG_SYNC_BOT_EMAIL }} + FG_SYNC_BOT_NAME: ${{ secrets.FG_SYNC_BOT_NAME }} + FG_SYNC_BRANCH: ${{ inputs.syncBranch }} diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index fc5ce8e..db78c6d 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -1,26 +1,25 @@ -name: Run tests +name: Unit Tests on: push: branches: - main pull_request: - types: [opened, synchronize, reopened, edited] - branches: - - main + types: [opened, synchronize, reopened] jobs: - build: + run-tests: + name: Running tests runs-on: ubuntu-latest strategy: matrix: - node-version: [18.x] + node-version: [20.x] steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 2 - name: Set up Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} @@ -34,7 +33,7 @@ jobs: run: xvfb-run -a npm test - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage/lcov.info diff --git a/blog/scripts/scripts.js b/blog/scripts/scripts.js index e9785d7..6f389f8 100644 --- a/blog/scripts/scripts.js +++ b/blog/scripts/scripts.js @@ -109,6 +109,14 @@ const CONFIG = { // geoRouting: 'on', productionDomain: 'business.adobe.com', prodDomains: ['business.adobe.com'], + stageDomainsMap: { + 'www.adobe.com': 'www.stage.adobe.com', + 'business.adobe.com': 'business.stage.adobe.com', + 'helpx.adobe.com': 'helpx.stage.adobe.com', + 'blog.adobe.com': 'blog.stage.adobe.com', + 'developer.adobe.com': 'developer-stage.adobe.com', + 'news.adobe.com': 'news.stage.adobe.com', + }, contentRoot: '/blog', codeRoot: '/blog', taxonomyRoot: '/tags', diff --git a/blog/scripts/utils.js b/blog/scripts/utils.js index 1ae323e..32afb0c 100644 --- a/blog/scripts/utils.js +++ b/blog/scripts/utils.js @@ -19,7 +19,7 @@ export const [setLibs, getLibs] = (() => { (prodLibs, location) => { libs = (() => { const { hostname, search } = location || window.location; - if (!(hostname.includes('.hlx.') || hostname.includes('local'))) return prodLibs; + if (!['.hlx.', '.stage.', 'local'].some((i) => hostname.includes(i))) return prodLibs; const branch = new URLSearchParams(search).get('milolibs') || 'main'; if (branch === 'local') return 'http://localhost:6456/libs'; return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`; @@ -69,10 +69,9 @@ function getImageCaption(picture) { // If the parent element doesn't have a caption, check if the next sibling does const parentSiblingEl = parentEl.nextElementSibling; - if (!parentSiblingEl || !parentSiblingEl.querySelector('picture')) return undefined; + if (!parentSiblingEl || !parentSiblingEl.querySelector('picture')) return ''; const firstChildEl = parentSiblingEl.firstChild; - caption = firstChildEl?.tagName === 'EM' ? firstChildEl : undefined; - return caption; + if (firstChildEl?.tagName === 'EM') return firstChildEl; } async function buildArticleHeader(el) { diff --git a/tools/sidekick/config.json b/tools/sidekick/config.json index edf1ec9..7cca55f 100644 --- a/tools/sidekick/config.json +++ b/tools/sidekick/config.json @@ -75,6 +75,16 @@ "passConfig": true, "includePaths": [ "**.xlsx**" ] }, + { + "containerId": "tools", + "id": "floodgate", + "title": "Floodgate", + "environments": [ "edit" ], + "url": "https://main--bacom-blog--adobecom.hlx.page/tools/floodgate?milolibs=floodgateui", + "passReferrer": true, + "passConfig": true, + "includePaths": [ "**.xlsx**" ] + }, { "containerId": "tools", "title": "Tag Selector",