MC CD #139
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: MC CD | |
on: | |
workflow_run: | |
workflows: ["MC CI"] | |
branches: [main] | |
types: | |
- completed | |
jobs: | |
deploy: | |
name: Deploy to Zaraz via Worker | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install dependencies for mc | |
working-directory: ./mc | |
run: npm ci | |
- name: Build | |
working-directory: ./mc | |
run: npm run build | |
- name: Create Worker | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
run: yes | npx managed-component-to-cloudflare-worker ./mc/dist/index.js custom-mc-counterscale ./wrangler.toml | |
release: | |
name: Release to GitHub Releases | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: deploy | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'mackenly' && github.ref == 'refs/heads/main' }} | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ./mc | |
- name: Build | |
run: npm run build | |
working-directory: ./mc | |
- name: Bump version and tag commit | |
id: versioning | |
uses: phips28/gh-action-bump-version@master | |
with: | |
tag-prefix: 'v' | |
patch-wording: 'bump-patch,fixes,Fixes,bugfix,Bugfix,patch,hotfix,Hotfix' | |
minor-wording: 'bump-minor,adds,Adds,new' | |
major-wording: 'bump-major,MAJOR' # ,removes,Removes,delete,Delete | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PACKAGEJSON_DIR: 'mc' | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag: ${{ steps.versioning.outputs.newTag }} | |
name: ${{ steps.versioning.outputs.newTag }} | |
generateReleaseNotes: true | |
draft: false | |
prerelease: false | |