deploy_to_cf_workers #1
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 | |
on: | |
push: | |
branches: | |
- main | |
repository_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Publish | |
uses: cloudflare/[email protected] | |
with: | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
preCommands: | | |
# Get jq | |
apt-get update -y && apt-get install -y jq | |
# Install packages | |
yarn | |
# Create the namespace if it doesn't exist | |
wrangler2 kv:namespace list | grep -q GmodExpress || wrangler2 kv:namespace create GmodExpress | |
# Get the namespace ID | |
namespaceid=$(wrangler2 kv:namespace list | jq '.[] | select(.title=="gmod-express-GmodExpress") | .id') | |
# Add the binding to the wrangler.toml | |
echo "kv_namespaces = [ { binding = 'GmodExpress', id = $namespaceid } ]" >> wrangler.toml |