Skip to content

Sync GitBook Docs

Sync GitBook Docs #2

name: Sync GitBook Docs
on:
workflow_dispatch:
inputs:
environment:
description: 'The environment used as target'
type: choice
required: true
default: dev
options:
- dev
- uat
- prod
# schedule:
# - cron: '0 23 * * *' # Run daily at midnight UTC
# Permissions needed for AWS OIDC authentication
permissions:
id-token: write
contents: read
jobs:
sync_gitbook_docs:
name: Sync gitbook Docs to S3 (manual on ${{ inputs.environment }})
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Checkout current repository
uses: actions/checkout@v4
- name: Checkout devportal-docs repo
uses: actions/checkout@v4
with:
repository: pagopa/devportal-docs
ref: docs/from-gitbook
path: devportal-docs
- name: Replace include tags in docs
run: |
bash apps/nextjs-website/scripts/replace-include-tags.sh devportal-docs/docs
- name: Configure AWS Credentials
uses: ./.github/actions/configure-aws-credentials
with:
aws_region: eu-south-1
role_to_assume: ${{ secrets.DEPLOY_IAM_ROLE }}
- name: Sync docs folder to S3
working-directory: ./devportal-docs
run: |
FIRST_LETTER="${{ inputs.environment }}"
FIRST_LETTER="${FIRST_LETTER:0:1}"
aws s3 sync docs s3://devportal-${FIRST_LETTER}-website-static-content/devportal-docs/docs --delete
- name: Trigger metadata generation
run: |
gh workflow run generate_all_metadata.yaml \
--field environment=${{ inputs.environment }} \
--field metadata_type=all
env:
GH_TOKEN: ${{ github.token }}
- name: Invalidate CloudFront asset bucket cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ vars.ASSET_BUCKET_CLOUDFRONT_DISTRIBUTION_ID }} \
--paths "/*"