Automatic build and deploy for Development environment #62
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-and-deploy | |
on: | |
pull_request: ~ | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: environment | |
required: true | |
description: Environment for deployment | |
release: | |
types: | |
- published | |
repository_dispatch: | |
types: | |
- content-updated | |
run-name: >- | |
${{ github.event_name == 'workflow_dispatch' && 'Manual' || 'Automatic' }} | |
build and deploy for | |
${{ inputs.environment || github.event.client_payload.environment || 'Development' }} environment | |
jobs: | |
update: | |
timeout-minutes: 5 | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ inputs.environment || github.event.client_payload.environment || 'Development' }} | |
url: ${{ steps.deploy_web.outputs.url }} | |
permissions: | |
contents: read | |
deployments: write | |
name: Publish WEB and API | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- name: Resolve Dependencies | |
run: bun install --frozen-lockfile | |
env: | |
HUSKY: 0 | |
- name: Convert environment name | |
id: env | |
run: |- | |
NAME_ORG="${{ inputs.environment || github.event.client_payload.environment || 'Development' }}" | |
NAME_LOWER=$(echo $NAME_ORG | awk '{ print tolower($0) }') | |
echo "name=$NAME_LOWER" >> $GITHUB_OUTPUT | |
- name: Build WEB | |
run: bun --cwd=apps/web run build --mode ${{ steps.env.outputs.name }} | |
env: | |
CONTENTFUL_DELIVERY_TOKEN: ${{ secrets.CONTENTFUL_DELIVERY_TOKEN }} | |
- name: Publish WEB to Cloudflare Pages | |
id: deploy_web | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: nordenwinds | |
directory: apps/web/dist | |
# gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
wranglerVersion: '3' | |
- name: Build and Publish API to Cloudflare Workers | |
id: deploy_api | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
command: deploy --env ${{ steps.env.outputs.name }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
workingDirectory: apps/functions | |