Skip to content

📝 chore: add README.md build status badge #36

📝 chore: add README.md build status badge

📝 chore: add README.md build status badge #36

Workflow file for this run

name: Deploy to Google Apps Script
on:
workflow_dispatch:
push:
branches: ['main', 'feature/*', 'refactor/*', '*fix/*']
release:
types: [published]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- name: Install clasp
id: install-clasp
run: sudo npm install @google/[email protected] -g
- name: Upsert CLASPRC_JSON secret to .clasprc.json file
id: write-clasprc
run: echo "$CLASPRC_JSON_SECRET" >> ~/.clasprc.json
env:
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }}
- name: Check clasp login status
id: clasp_login
run: clasp login --status
- name: Save current .clasprc.json contents to CLASPRC_JSON_FILE environment variable
id: save-clasprc
run: |
echo ::add-mask::$(tr -d '\n\r' < ~/.clasprc.json)
echo "CLASPRC_JSON_FILE=$(tr -d '\n\r' < ~/.clasprc.json)" >> $GITHUB_ENV
- name: Save CLASPRC_JSON_FILE environment variable to CLASPRC_JSON repo secret
id: set-clasprc-secret
if: ${{ env.CLASPRC_JSON_FILE != env.CLASPRC_JSON_SECRET }}
uses: hmanzur/[email protected]
env:
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }}
with:
name: "CLASPRC_JSON"
value: ${{ env.CLASPRC_JSON_FILE }}
repository: ${{ github.repository }}
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Checkout repo
id: checkout-repo
uses: actions/checkout@v2
- name: Set scriptId in .clasp.json file
id: set-script-id
if: ${{env.SCRIPT_ID}}
run: jq '.scriptId = "${{env.SCRIPT_ID}}"' .clasp.json > /tmp/.clasp.json && mv /tmp/.clasp.json .clasp.json
env:
SCRIPT_ID: ${{secrets.SCRIPT_ID}}
- name: Push script to scripts.google.com
id: clasp-push
run: clasp push -f
- name: Deploy Script
id: clasp-deploy
if: ${{env.DEPLOYMENT_ID && (github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/main'))}}
run: clasp deploy -i "$DEPLOYMENT_ID" -d "$GITHUB_REF"
env:
DEPLOYMENT_ID: ${{ secrets.DEPLOYMENT_ID }}
# Release / Version / Tag
- name: Use GitVersion
id: git-version
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Git Tag
if: github.ref == 'refs/heads/main'
run: |
git config --local user.name "github-actions"
git config --local user.email "[email protected]"
git tag -a "${{ steps.gitversion.outputs.fullSemVer }}" -m "Version ${{ steps.gitversion.outputs.fullSemVer }}"
git push origin "${{ steps.gitversion.outputs.fullSemVer }}"
- name: Create GitHub Release
if: github.ref == 'refs/heads/main'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{ steps.gitversion.outputs.fullSemVer }}"
release_name: "Release ${{ steps.gitversion.outputs.fullSemVer }}"
draft: false
prerelease: false