Skip to content

feat: Implement CI #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/actions/gcloud/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: gcloud
description: gcloud authentication

inputs:
credentials_json:
description: "The JSON key for authenticating with Google Cloud."
required: true
project_id:
description: "The Google Cloud project ID."
required: true
modules_token:
description: "The token for accessing private modules."
required: true

runs:
using: "composite"
steps:
- name: ✅ Checkout code
uses: actions/checkout@v4

- name: 😈 Auth with Gcloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ inputs.credentials_json }}

- name: 🔧 Set up Gcloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ inputs.project_id }}

- name: 🐳 Register gcloud as a Docker credential helper
shell: bash
run: gcloud auth configure-docker

- name: 🥷 Granting Private Modules Access
shell: bash
run: |
git config --global url."https://${{ inputs.modules_token }}:[email protected]/zesty-io".insteadOf "https://github.com/zesty-io"
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Ci

on:
pull_request:
branches: [master]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-test:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18, 20, 22]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

# Reusable workflow
- name: Authenticate in Gcloud
uses: ./.github/actions/gcloud
with:
credentials_json: ${{ secrets.GCP_DEV_SA_KEY }}
project_id: zesty-dev
modules_token: ${{ secrets.GO_MODULES_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Write the .env file
run: |
echo '${{ secrets.ENV_FILE }}' > .env

- name: Install dependencies
run: npm install

- name: 🧪 Run unit tests
run: npm run test

tests-pass:
needs: [build-test]

if: always()
runs-on: ubuntu-latest
name: 🚀🚀🚀 Ok to Merge 😎 👍👍👍
steps:
- run: exit 1
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }}
Loading