contentful-publish #602
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: Deploy Production | |
on: | |
push: | |
branches: [main] | |
repository_dispatch: | |
types: [contentful-publish] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Restore cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.npm | |
${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Install dependencies | |
run: npm ci | |
- name: 'Set timezone' | |
uses: szenius/set-timezone@v1.0 | |
with: | |
timezoneLinux: 'Europe/Helsinki' | |
timezoneMacos: 'Europe/Helsinki' | |
timezoneWindows: 'Helsinki Standard Time' | |
- name: Production Build | |
env: | |
CONTENTFUL_SPACE_ID: ${{ secrets.CONTENTFUL_SPACE_ID }} | |
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_ACCESS_TOKEN }} | |
NEXT_PUBLIC_GOOGLE_CALENDAR_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_CALENDAR_ID }} | |
NEXT_PUBLIC_GOOGLE_CALENDAR_API_KEY: ${{ secrets.NEXT_PUBLIC_GOOGLE_CALENDAR_API_KEY }} | |
NEXT_PUBLIC_GOOGLE_CALENDAR_SHARE_URL: ${{ secrets.NEXT_PUBLIC_GOOGLE_CALENDAR_SHARE_URL }} | |
NEXT_PUBLIC_METADATA_API: ${{ secrets.NEXT_PUBLIC_METADATA_API }} | |
NEXT_PUBLIC_PLAYER_MODE: ${{ secrets.NEXT_PUBLIC_PLAYER_MODE_PROD }} | |
NEXT_PUBLIC_SHOUTBOX_SOURCE: ${{ secrets.NEXT_PUBLIC_SHOUTBOX_SOURCE }} | |
NEXT_PUBLIC_SHOW_START_TIME: ${{ secrets.NEXT_PUBLIC_SHOW_START_TIME}} | |
GA_API_KEY: ${{ secrets.GA_API_KEY}} | |
GA_TYPE: ${{ secrets.GA_TYPE}} | |
GA_PROJECT_ID: ${{ secrets.GA_PROJECT_ID}} | |
GA_PRIVATE_KEY_ID: ${{ secrets.GA_PRIVATE_KEY_ID}} | |
GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY}} | |
GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL}} | |
GA_CLIENT_ID: ${{ secrets.GA_CLIENT_ID}} | |
GA_AUTH_URI: ${{ secrets.GA_AUTH_URI}} | |
GA_TOKEN_URI: ${{ secrets.GA_TOKEN_URI}} | |
GA_AUTH_PROVIDER_X509_CERT_URL: ${{ secrets.GA_AUTH_PROVIDER_X509_CERT_URL}} | |
GA_CLIENT_X509_CERT_URL: ${{ secrets.GA_CLIENT_X509_CERT_URL}} | |
GA_SPREADSHEET_SHOWLIST: ${{ secrets.GA_SPREADSHEET_SHOWLIST}} | |
GA_SPREADSHEET_RANGE: ${{ secrets.GA_SPREADSHEET_RANGE}} | |
run: npm run build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-north-1 | |
- name: Deploy to AWS S3 | |
run: ./scripts/s3-upload.sh | |
env: | |
S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_PROD }} |