Build developer docs #41
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
name: Create developer docs | |
runs-on: ubuntu-latest | |
container: ruby:2.7.8 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- 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: Share to upload | |
uses: actions/upload-artifact@master | |
with: | |
name: build | |
path: ./build | |
upload: | |
name: Upload to S3 | |
runs-on: ubuntu-latest | |
needs: create | |
steps: | |
- name: Download from create | |
uses: actions/download-artifact@master | |
with: | |
name: build | |
path: ./build | |
- 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: 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 ${{ secrets.CF_DISTRIBUTION_ID }} --paths "/*" | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |