Refactor workflows to update valueFile path in deploy.yml #11
Workflow file for this run
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 | |
on: | |
push: | |
tags: | |
- 'v/*' | |
workflow_dispatch: | |
jobs: | |
test: | |
name: 🧪 Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⬇️ Checkout | |
uses: actions/checkout@v4 | |
- name: 📦 Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: 📦 Install Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: 'pnpm' | |
- name: 💽 Setup Enviroment | |
run: | | |
cp wrangler.example.toml wrangler.toml | |
echo "[vars]" >> wrangler.toml | |
echo "AUTH_SECRET = \"production_value\" " >> wrangler.toml | |
echo "[[kv_namespaces]]" >> wrangler.toml | |
echo "binding = \"SHORT_URLS\"" >> wrangler.toml | |
echo "id = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"" >> wrangler.toml | |
env: | |
KV_NAMESPACE_ID: ${{ secrets.CF_KV_ID }} | |
- name: ⚙️ Install Dependencies | |
run: pnpm install --frozen-lockfile | |
- name: 📋 Test | |
run: pnpm test | |
deploy: | |
name: 🚀 Deploy | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: ⬇️ Checkout | |
uses: actions/checkout@v4 | |
- name: 📦 Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: 💽 Setup Enviroment | |
# echo "[vars]" >> wrangler.toml | |
# echo "AUTH_SECRET = \"${SHORT_API_KEY}\" " >> wrangler.toml | |
run: | | |
cp wrangler.example.toml wrangler.toml | |
[ -z ${SHORT_API_KEY+x} ] && echo "No API Key" || echo "[vars]" >> wrangler.toml; | |
[ -z ${SHORT_API_KEY+x} ] && echo "No API Key" || echo "AUTH_SECRET = \"${SHORT_API_KEY}\" " >> wrangler.toml; | |
echo "[[kv_namespaces]]" >> wrangler.toml | |
echo "binding = \"SHORT_URLS\"" >> wrangler.toml | |
echo "id = \"${KV_NAMESPACE_ID}\"" >> wrangler.toml | |
env: | |
SHORT_API_KEY: ${{ secrets.SHORT_API_KEY }} | |
KV_NAMESPACE_ID: ${{ secrets.CF_KV_ID }} | |
- name: 🌑 Deploy | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
updateapi: | |
if: github.repository == 'jqshuv/short' | |
name: 📈 Change API Version | |
runs-on: ubuntu-latest | |
needs: deploy | |
steps: | |
- name: ⬇️ Checkout | |
uses: actions/checkout@v4 | |
- name: 🔩 Configure Version | |
uses: fjogeleit/yaml-update-action@v0.15.0 | |
with: | |
valueFile: 'docs/api-docs.yaml' | |
propertyPath: 'info.version' | |
method: 'Update' | |
branch: 'main' | |
masterBranchName: 'main' | |
value: '${GITHUB_REF#refs/tags/v}' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commitUserName: ${{ secrets.GH_NAME }} | |
commitUserEmail: ${{ secrets.GH_EMAIL }} | |
commitChange: true | |
message: 'refactor: update API version to ${GITHUB_REF#refs/tags/v}' | |