Skip to content
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

Update dependencies, update actions #15

Merged
merged 6 commits into from
Dec 22, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: ['main']
schedule:
- cron: '44 18 * * 6'
- cron: '55 12 * * 2'

jobs:
analyze:
Expand Down
41 changes: 28 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: Run tests and deploy to Cloud Run

on:
push:
branches:
- 'main'
- '**' # Run on any branch

env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
RUN_REGION: us-central1
SERVICE_NAME: ${{ secrets.GCP_SERVICE_NAME }}
on: [push]

jobs:
test:
name: Run tests
Expand All @@ -14,41 +21,49 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install npm dependencies
run: npm install
- name: Run jest unit tests
run: npm run test
- name: Run JS linter
run: npm run lint

deploy:
name: Deploy to Cloud Run
name: Build and deploy to Cloud Run
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
if: github.ref_name == 'main'
steps:
- uses: actions/checkout@v4

- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v0
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY_JSON }}

- name: Authorize Docker push
run: gcloud auth configure-docker
# Docker auth
- name: Docker Auth
uses: docker/login-action@v3
with:
registry: 'gcr.io'
username: _json_key
password: ${{ secrets.GCP_SA_KEY_JSON }}

# Docker build & push to GCP
- name: Build and Push Container
run: |-
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }} --build-arg GITHUB_SHA_ARG=${{ github.sha }} .
docker buildx build --platform linux/amd64 -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }} --build-arg GITHUB_SHA_ARG=${{ github.sha }} .
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }}

# Deploy the container that was just pushed
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v0
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.SERVICE_NAME }}
image: gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }}
image: gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }}
region: ${{ env.RUN_REGION }}

- name: Use gcloud CLI
run: gcloud info
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ TODO
- Last updated on the page
- Compile 5 more groundhogs
- Add merch!
- Look through wikipedia
- TODO: years on groundhogs page
- Also, show active groundhogs by default

Expand Down
Loading
Loading