Skip to content

Development workflow #17

Development workflow

Development workflow #17

Workflow file for this run

name: Development workflow
# When workflow is triggered
on:
repository_dispatch:
workflow_dispatch:
inputs:
cms:
description: cms
required: true
type: choice
default: production
options:
- production
- workshop
tag:
description: tag; default is what's on main
required: false
jobs:
build-development:
runs-on: ubuntu-latest
environment: development
steps:
- name: set drupal url
id: cms_check
run: |
if [ "${{ github.event.inputs.cms }}" == "production" ]; then
echo 'DRUPAL_URL=${{ vars.DRUPAL_URL }}' >> $GITHUB_ENV
else
echo 'DRUPAL_URL=${{ vars.WORKSHOP_DRUPAL_URL }}' >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check that the tag exists in repo
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }}
id: tag_check
run: |
if git rev-parse 'refs/tags/${{ github.event.inputs.tag }}' &> /dev/null; then
echo 'tag=${{ github.event.inputs.tag }}' >> $GITHUB_ENV
elif git rev-parse '${{ github.event.inputs.tag }}' &> /dev/null; then
echo "tag=`git rev-parse '${{ github.event.inputs.tag }}'`" >> $GITHUB_ENV
else
echo "Couldn't figure out tag from input: ${{ github.event.inputs.tag }}"
echo "Aborting deployment."
false
fi
- name: Checkout correct repository
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }}
uses: actions/checkout@v3
with:
ref: ${{ env.tag }}
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- run: npm install
- run: npm run build
env:
DRUPAL_URL: ${{ env.DRUPAL_URL }}
DRUPAL_AUTH: ${{ secrets.DRUPAL_AUTH }}
- name: Deploy to netlify
run: npx netlify-cli deploy --dir=public --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }}
- name: Send custom JSON data to Slack workflow
if: ${{ failure() }}
uses: slackapi/[email protected]
with:
payload: |
{
"url": "https://github.com/mlibrary/design-system-docs/actions/runs/${{ github.run_id }}",
"message": "Development build and deploy failed"
}
env:
SLACK_WEBHOOK_URL: ${{ vars.SLACK_BUILD_FAIL_URL }}