-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: stripe-warden CI/CD DEV | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-deploy: | ||
env: | ||
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | ||
SERVICE: ${{ secrets.GCP_SERVICE }} | ||
REGION: ${{ secrets.GCP_REGION }} | ||
TAG: latest | ||
runs-on: ubuntu-latest | ||
environment: development | ||
steps: | ||
# checkout the repo | ||
- name: "Checkout GitHub Action" | ||
uses: actions/checkout@master | ||
|
||
# Authenticate to Google Cloud | ||
- name: Google Auth | ||
id: auth | ||
uses: "google-github-actions/auth@v2" | ||
with: | ||
credentials_json: "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | ||
|
||
# Authenticate Docker to Google Cloud Artifact Registry | ||
- name: Docker Auth | ||
id: docker-auth | ||
uses: "docker/login-action@v3" | ||
with: | ||
username: _json_key | ||
password: "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | ||
registry: "${{ env.REGION }}-docker.pkg.dev" | ||
|
||
# Build and push the Docker image | ||
- name: Build and Push Container | ||
run: |- | ||
cd packages/stripe-warden && | ||
docker build \ | ||
-f Dockerfile \ | ||
-t "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" . | ||
echo "=== IMAGE NAME: ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" | ||
docker push "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" | ||
# Deploy to Cloud Run | ||
- name: Deploy to Cloud Run | ||
run: | | ||
gcloud run deploy ${{ env.SERVICE }} \ | ||
--platform=managed \ | ||
--port=3000 \ | ||
--region=${{ env.REGION }} \ | ||
--image="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" \ | ||
--min-instances=0 \ | ||
--max-instances=1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM oven/bun:latest as base | ||
WORKDIR /usr/src/app | ||
|
||
COPY . . | ||
RUN bun install | ||
|
||
ENV NODE_ENV=production | ||
ENV PORT=3000 | ||
|
||
RUN chown -R bun:bun ./ | ||
|
||
USER bun | ||
EXPOSE 3000/tcp | ||
CMD [ "bun", "run", "src/index.ts" ] |
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