Skip to content

Build developer docs #38

Build developer docs

Build developer docs #38

Workflow file for this run

name: Build developer docs
run-name: Build developer docs
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
branches:
- '*'
push:
branches:
- main
jobs:
create-and-upload:
name: Create developer docs and upload them to S3
runs-on: ubuntu-latest
container: ruby:2.7.8
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Resolve environment variables
uses: FranzDiebold/github-env-vars-action@v2
- name: Extract and set lowercase branch name
run: echo "BRANCH_NAME=$CI_ACTION_REF_NAME_SLUG" >> $GITHUB_ENV
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Create docs
run: |
gem install ffi -v 1.16.0
gem install dotenv -v 2.8.1
gem install public_suffix -v 5.1.1
gem install middleman -v 4.2.1
bundle install
bundle exec middleman build --clean
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
aws-region: eu-west-1
- name: Upload to S3 (acc)
if: ${{ env.BRANCH_NAME != 'master' }}
run: aws s3 cp ./build s3://cf-site-api-docs/staging --recursive --acl private
- name: Upload to S3 (prod)
if: ${{ env.BRANCH_NAME == 'master' }}
run: aws s3 cp ./build s3://cf-site-api-docs/ --recursive --acl private
- name: Bust cloudfront cache
if: ${{ env.BRANCH_NAME == 'master' }}
run: aws cloudfront create-invalidation --distribution-id ${{ env.CF_DISTRIBUTION_ID }} --paths "/*"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}