Build and deploy #2
This file contains hidden or 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: | |
| # push: | |
| # branches: | |
| # - master | |
| # - main | |
| workflow_dispatch: | |
| inputs: | |
| cf_env: | |
| description: Choose environment | |
| type: choice | |
| required: true | |
| options: | |
| - dev | |
| - staging | |
| - prod | |
| default: dev | |
| branch: | |
| description: Choose branch or tag, defaults to main | |
| type: string | |
| required: true | |
| default: main | |
| emsdk_version: | |
| description: Emscripten SDK version, defaults to latest | |
| type: string | |
| required: false | |
| default: latest | |
| preCommand: | |
| description: Provide a bash script to execute before running wrangler | |
| type: string | |
| required: false | |
| default: echo "No script provided for execution before running Wrangler. Moving along." | |
| postCommand: | |
| description: Provide a bash script to execute after running wrangler | |
| type: string | |
| required: false | |
| default: echo "Nothing to execute after running Wrangler. Finishing..." | |
| jobs: | |
| deploy: | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ inputs.branch }} | |
| - name: Set environment variables | |
| run: | | |
| if [[ "${{ inputs.cf_env }}" == "dev" ]]; then | |
| echo "CF_ACCOUNT=DEV_ACCOUNT_ID" >> "$GITHUB_ENV" | |
| echo "CF_TOKEN=JITSI_CF_DEV_TOKEN" >> "$GITHUB_ENV" | |
| elif [[ "${{ inputs.cf_env }}" == "staging" ]]; then | |
| echo "CF_ACCOUNT=STAGE_ACCOUNT_ID" >> "$GITHUB_ENV" | |
| echo "CF_TOKEN=JITSI_CF_STAGING_TOKEN" >> "$GITHUB_ENV" | |
| elif [[ "${{ inputs.cf_env }}" == "prod" ]]; then | |
| echo "CF_ACCOUNT=PROD_ACCOUNT_ID" >> "$GITHUB_ENV" | |
| echo "CF_TOKEN=JITSI_CF_PROD_TOKEN" >> "$GITHUB_ENV" | |
| else | |
| echo "Invalid environment specified: ${{ inputs.cf_env }}, exiting." | |
| exit 1 | |
| fi | |
| - name: Install Linux deps | |
| run: | | |
| sudo apt update | |
| sudo apt -y install wget unzip libopus-dev | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Setup Emscripten SDK | |
| run: | | |
| wget https://github.com/emscripten-core/emsdk/archive/main.zip | |
| unzip main.zip | |
| cd emsdk-main | |
| ./emsdk install ${{ inputs.emsdk_version }} | |
| ./emsdk activate ${{ inputs.emsdk_version }} | |
| source ./emsdk_env.sh | |
| echo "EMSDK=$EMSDK" >> $GITHUB_ENV | |
| echo "EM_CONFIG=$EM_CONFIG" >> $GITHUB_ENV | |
| echo "$EMSDK:$EMSDK/upstream/emscripten" >> $GITHUB_PATH | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| - name: Build ts app | |
| run: | | |
| npm run build | |
| - name: Wrangler Deploy | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| wranglerVersion: "4.40.2" | |
| apiToken: ${{ secrets[env.CF_TOKEN] }} | |
| accountId: ${{ secrets[env.CF_ACCOUNT] }} | |
| preCommands: ${{ inputs.preCommand }} | |
| postCommands: ${{ inputs.postCommand }} | |
| command: deploy |