Created
November 27, 2022 21:39
-
-
Save stekhn/685279a5240738a1db820ce80f2ca9e8 to your computer and use it in GitHub Desktop.
Github Action for building a web application and deploying it to a Google Cloud Storage bucket
This file contains hidden or 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
# Set up Node.js action: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
# Set up Google Cloud auth action: https://github.com/google-github-actions/auth#usage | |
# Set up Google Cloud workload identity federation: https://github.com/marketplace/actions/authenticate-to-google-cloud#setting-up-workload-identity-federation | |
# Upload to Google Cloud Storage: https://github.com/google-github-actions/upload-cloud-storage | |
name: CI/CD | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
branches: ['main'] | |
jobs: | |
build-and-deploy: | |
name: Build & Deploy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: yarn | |
- name: Install dependencies | |
run: yarn install --prefer-offline | |
- name: Build project | |
run: yarn build | |
- name: Authenticate Github Action | |
uses: google-github-actions/auth@v0 | |
with: | |
workload_identity_provider: ${{ secrets.GCP_WIP }} | |
service_account: ${{ secrets.GCP_SA }} | |
- name: Upload build to Google Cloud Storage | |
uses: google-github-actions/upload-cloud-storage@v0 | |
with: | |
path: public | |
destination: my-bucket | |
parent: false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment