Skip to content

Publish (site_mode: testing) #74

Publish (site_mode: testing)

Publish (site_mode: testing) #74

Workflow file for this run

name: Publish
run-name: "Publish (site_mode: ${{github.event.inputs.site_mode}})"
on:
workflow_dispatch:
inputs:
site_mode:
description: Site mode
required: true
default: testing
type: choice
options:
- development
- testing
- production
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Persist Site Cache
uses: actions/cache@v3
with:
path: site/.cache
key: site-cache
- name: Setup mise
uses: jdx/mise-action@v2
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build Packages
run: pnpm build
- name: Build Site
timeout-minutes: 120
working-directory: site
run: |
m="${{github.event.inputs.site_mode}}"
if [ "$m" = "production" ]; then
/usr/bin/time --verbose pnpm build:prod
elif [ "$m" = "testing" ]; then
/usr/bin/time --verbose pnpm build:test
elif [ "$m" = "development" ]; then
/usr/bin/time --verbose pnpm build:dev
else
echo "Invalid site mode: $m"
exit 1
fi
- name: Setup AWS Environment
run: |
m="${{github.event.inputs.site_mode}}"
if [ "$m" = "production" ]; then
echo "AWS_BUCKET_URL=s3://api2static.onlyoffice.com" >> "$GITHUB_ENV"
echo "AWS_ACCESS_KEY_ID=${{secrets.ACCESS_KEY_PROD}}" >> "$GITHUB_ENV"
echo "AWS_SECRET_ACCESS_KEY=${{secrets.SECRET_KEY_PROD}}" >> "$GITHUB_ENV"
echo "AWS_REGION=us-west-2" >> "$GITHUB_ENV"
echo "AWS_DISTRIBUTION_ID=${{secrets.AWS_DISTRIBUTION_ID_PROD}}" >> "$GITHUB_ENV"
elif [ "$m" = "testing" ]; then
echo "AWS_BUCKET_URL=s3://api2static.teamlab.info" >> "$GITHUB_ENV"
echo "AWS_ACCESS_KEY_ID=${{secrets.ACCESS_KEY}}" >> "$GITHUB_ENV"
echo "AWS_SECRET_ACCESS_KEY=${{secrets.SECRET_KEY}}" >> "$GITHUB_ENV"
echo "AWS_DISTRIBUTION_ID=${{secrets.AWS_DISTRIBUTION_ID}}" >> "$GITHUB_ENV"
echo "AWS_REGION=us-east-1" >> "$GITHUB_ENV"
elif [ "$m" = "development" ]; then
echo "Development bucket dose not exist"
exit 1
else
echo "Invalid site mode: $m"
exit 1
fi
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{env.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{env.AWS_SECRET_ACCESS_KEY}}
aws-region: ${{env.AWS_REGION}}
- name: Sync AWS Bucket
working-directory: site/dist
run: aws s3 sync . ${{env.AWS_BUCKET_URL}} --delete
- name: Invalidate AWS CloudFront Cache
run: aws cloudfront create-invalidation --distribution-id ${{env.AWS_DISTRIBUTION_ID}} --paths '/*'