release from tag #4
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: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
name: Build & Deploy to Cloud Storage | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
run: yarn install | |
- name: Build project | |
run: yarn build | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCP_CREDENTIALS }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Deploy to Google Cloud Storage | |
run: gsutil -m rsync -r build gs://${{ vars.BUCKET_NAME }} | |
tag-new-version: | |
name: Tag new version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Read the version from package.json | |
id: get_version | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const packageJson = fs.readFileSync('./package.json', 'utf8'); | |
const version = JSON.parse(packageJson).version; | |
core.setOutput('version', version); | |
- name: Check if tag exists | |
id: check_tag | |
uses: mukunku/tag-exists-action@v1.6.0 | |
with: | |
tag: v${{ steps.get_version.outputs.version }} | |
- name: Create new tag | |
if: steps.check_tag.outputs.exists == 'false' | |
uses: rickstaa/action-create-tag@v1.7 | |
with: | |
tag: v${{ steps.get_version.outputs.version }} | |
message: v${{ steps.get_version.outputs.version }} |