Skip to content

Commit

Permalink
add modified deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
melissag-ensemble committed Oct 1, 2024
1 parent 62fad4d commit 06b1618
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 71 deletions.
167 changes: 96 additions & 71 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,12 @@ jobs:
- run: echo "Path prefix - ${{ needs.set-state.outputs.path_prefix }}"
- run: echo "Exclude subfolder - ${{ needs.set-state.outputs.exclude_subfolder }}"

pre-build-dev:
needs: [set-state]
runs-on: ubuntu-latest
if: needs.set-state.outputs.deploy_dev == 'true'
steps:
- name: check dev azure connection string
if: env.AIO_AZURE_DEV_CONNECTION_STRING == null
run: |
echo "::error::Please set the Azure Blob Storage connection string as AIO_AZURE_DEV_CONNECTION_STRING in Github Secrets"
exit 1
env:
AIO_AZURE_DEV_CONNECTION_STRING: ${{ secrets.AIO_AZURE_DEV_CONNECTION_STRING }}

build-dev:
defaults:
run:
shell: bash
needs: [set-state, pre-build-dev]
needs: [set-state]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -105,67 +93,104 @@ jobs:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
with:
cmd: install

- name: Gatsby Cache
uses: actions/cache@v2
with:
path: |
public
.cache
key: ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{ github.run_id }}
restore-keys: |
${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-
- name: Clean Cache
if: needs.set-state.outputs.clean_cache == 'true'
- name: Build navigation file
uses: borales/actions-yarn@v3
with:
cmd: clean
cmd: buildNavigation
- name: Publish markdown files in ./src/pages
run: |
bash .github/scripts/publish-mds.sh "./src/pages" "${{ needs.set-state.outputs.path_prefix }}"
- name: Build site
uses: borales/actions-yarn@v3
with:
cmd: build
env:
PREFIX_PATHS: true # equivalent to --prefix-paths flag for 'gatsby build'
PATH_PREFIX: ${{ needs.set-state.outputs.path_prefix }}
GATSBY_ADOBE_LAUNCH_SRC: ${{ secrets.AIO_ADOBE_LAUNCH_DEV_SRC }}
GATSBY_ADDITIONAL_ADOBE_ANALYTICS_ACCOUNTS: ${{ secrets.AIO_REPORT_SUITE_DEV}}
GATSBY_ADOBE_ANALYTICS_ENV: "dev"
REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_OWNER: ${{ github.event.repository.owner.login }}
REPO_NAME: ${{ github.event.repository.name }}
REPO_BRANCH: ${{ needs.set-state.outputs.branch_short_ref }}
GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}
GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
GOOGLE_DOCS_TOKEN: ${{ secrets.GOOGLE_DOCS_TOKEN }}
GOOGLE_DOCS_FOLDER_ID: ${{ secrets.GOOGLE_DOCS_FOLDER_ID }}
GATSBY_IMS_SRC: ${{ secrets.AIO_IMS_DEV_SRC }}
GATSBY_IMS_CONFIG: ${{ secrets.AIO_IMS_DEV_CONFIG }}
GATSBY_ALGOLIA_APPLICATION_ID: ${{ secrets.AIO_ALGOLIA_APPLICATION_ID }}
GATSBY_ALGOLIA_SEARCH_API_KEY: ${{ secrets.AIO_ALGOLIA_SEARCH_API_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ secrets.AIO_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_API_KEY: ${{ secrets.AIO_ALGOLIA_API_KEY }}
GATSBY_ALGOLIA_INDEX_ALL_SRC: ${{ secrets.AIO_ALGOLIA_INDEX_ALL_SRC }}
GATSBY_ALGOLIA_SEARCH_INDEX: ${{ secrets.AIO_ALGOLIA_SEARCH_INDEX }}
GATSBY_ALGOLIA_INDEX_ENV_PREFIX: ${{ secrets.AIO_ALGOLIA_INDEX_ENV_PREFIX }}
GATSBY_FEDS_PRIVACY_ID: ${{ secrets.AIO_FEDS_PRIVACY_ID }}
GATSBY_SITE_DOMAIN_URL: https://developer-stage.adobe.com
# - name: Gatsby Cache
# uses: actions/cache@v2
# with:
# path: |
# public
# .cache
# key: ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{ github.run_id }}
# restore-keys: |
# ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-

- name: Deploy
uses: AdobeDocs/static-website-deploy@master
with:
enabled-static-website: "true"
source: "public"
target: ${{ needs.set-state.outputs.path_prefix }}
connection-string: ${{ secrets.AIO_AZURE_DEV_CONNECTION_STRING }}
remove-existing-files: "true"
exclude-subfolder: ${{ needs.set-state.outputs.exclude_subfolder }}
- name: Purge Fastly Cache
uses: AdobeDocs/gatsby-fastly-purge-action@master
with:
fastly-token: ${{ secrets.AIO_FASTLY_TOKEN }}
fastly-url: "${{ secrets.AIO_FASTLY_DEV_URL}}${{ needs.set-state.outputs.path_prefix }}"
# - name: Clean Cache
# if: needs.set-state.outputs.clean_cache == 'true'
# uses: borales/actions-yarn@v3
# with:
# cmd: clean

# - name: Build site
# uses: borales/actions-yarn@v3
# with:
# cmd: build
# env:
# PREFIX_PATHS: true # equivalent to --prefix-paths flag for 'gatsby build'
# PATH_PREFIX: ${{ needs.set-state.outputs.path_prefix }}
# GATSBY_ADOBE_LAUNCH_SRC: ${{ secrets.AIO_ADOBE_LAUNCH_DEV_SRC }}
# GATSBY_ADDITIONAL_ADOBE_ANALYTICS_ACCOUNTS: ${{ secrets.AIO_REPORT_SUITE_DEV}}
# GATSBY_ADOBE_ANALYTICS_ENV: "dev"
# REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# REPO_OWNER: ${{ github.event.repository.owner.login }}
# REPO_NAME: ${{ github.event.repository.name }}
# REPO_BRANCH: ${{ needs.set-state.outputs.branch_short_ref }}
# GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}
# GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
# GOOGLE_DOCS_TOKEN: ${{ secrets.GOOGLE_DOCS_TOKEN }}
# GOOGLE_DOCS_FOLDER_ID: ${{ secrets.GOOGLE_DOCS_FOLDER_ID }}
# GATSBY_IMS_SRC: ${{ secrets.AIO_IMS_DEV_SRC }}
# GATSBY_IMS_CONFIG: ${{ secrets.AIO_IMS_DEV_CONFIG }}
# GATSBY_ALGOLIA_APPLICATION_ID: ${{ secrets.AIO_ALGOLIA_APPLICATION_ID }}
# GATSBY_ALGOLIA_SEARCH_API_KEY: ${{ secrets.AIO_ALGOLIA_SEARCH_API_KEY }}
# GATSBY_ALGOLIA_APP_ID: ${{ secrets.AIO_ALGOLIA_APP_ID }}
# GATSBY_ALGOLIA_API_KEY: ${{ secrets.AIO_ALGOLIA_API_KEY }}
# GATSBY_ALGOLIA_INDEX_ALL_SRC: ${{ secrets.AIO_ALGOLIA_INDEX_ALL_SRC }}
# GATSBY_ALGOLIA_SEARCH_INDEX: ${{ secrets.AIO_ALGOLIA_SEARCH_INDEX }}
# GATSBY_ALGOLIA_INDEX_ENV_PREFIX: ${{ secrets.AIO_ALGOLIA_INDEX_ENV_PREFIX }}
# GATSBY_FEDS_PRIVACY_ID: ${{ secrets.AIO_FEDS_PRIVACY_ID }}
# GATSBY_SITE_DOMAIN_URL: https://developer-stage.adobe.com

# - name: Deploy
# uses: AdobeDocs/static-website-deploy@master
# with:
# enabled-static-website: "true"
# source: "public"
# target: ${{ needs.set-state.outputs.path_prefix }}
# connection-string: ${{ secrets.AIO_AZURE_DEV_CONNECTION_STRING }}
# remove-existing-files: "true"
# exclude-subfolder: ${{ needs.set-state.outputs.exclude_subfolder }}
# - name: Purge Fastly Cache
# uses: AdobeDocs/gatsby-fastly-purge-action@master
# with:
# fastly-token: ${{ secrets.AIO_FASTLY_TOKEN }}
# fastly-url: "${{ secrets.AIO_FASTLY_DEV_URL}}${{ needs.set-state.outputs.path_prefix }}"

# publish-dev:
# needs: [set-state, build-dev]
# runs-on: ubuntu-latest
# defaults:
# run:
# shell: bash
# if: needs.set-state.outputs.deploy_dev == 'true'
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Publish markdown files in ./src/pages
# run: |
# bash .github/scripts/publish-mds.sh "./src/pages" "${{ needs.set-state.outputs.path_prefix }}"


publish-production:
needs: [set-state]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
if: needs.set-state.outputs.deploy_prod == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Publish markdown files in ./src/pages
run: |
bash .github/scripts/publish-mds.sh "./src/pages" "${{ needs.set-state.outputs.path_prefix }}"
pre-build-production:
needs: [set-state]
Expand Down Expand Up @@ -271,4 +296,4 @@ jobs:
uses: AdobeDocs/gatsby-fastly-purge-action@master
with:
fastly-token: ${{ secrets.AIO_FASTLY_TOKEN }}
fastly-url: "${{ secrets.AIO_FASTLY_PROD_URL }}${{ needs.set-state.outputs.path_prefix }}"
fastly-url: "${{ secrets.AIO_FASTLY_PROD_URL }}${{ needs.set-state.outputs.path_prefix }}"
20 changes: 20 additions & 0 deletions scripts/publish-mds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

home="https://admin.hlx.page/preview/adobedocs/adp-devsite/main"
root=$1
path_prefix=$2

publish()
{
filename=$1
to_remove="$root/"
relative_filename=${filename/#$to_remove}
url="${home}${path_prefix}${relative_filename}"

echo ""
echo "curl -XPOST -vi ${url}"
curl -XPOST -vi "${url}"
}

# TODO: may want to only certain types of files up
find "${root}" -type f -name "*.md" -exec echo "{}" \; | while read i; do publish $i; done

0 comments on commit 06b1618

Please sign in to comment.