Skip to content

Commit

Permalink
Add prod workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SwapnilAryan97 committed May 15, 2024
1 parent 584f003 commit 6d269fa
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Production Workflow

on:
push:
branches:
- 'master'
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
env:
EMAILJS_PUBLIC_KEY: ${{ secrets.EMAIL_TOKEN }}

build-container:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to Heroku Container Registry
run: docker login --email=${{ secrets.HEROKU_EMAIL }} --password=${{ secrets.HEROKU_API_KEY }} registry.heroku.com

- name: Build and push Docker image
run:
docker build -t registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web .
docker push registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web

- name: Install Heroku CLI
run: |
curl https://cli-assets.heroku.com/install.sh | sh
- name: Release Docker image
run: |
heroku container:release web --app ${{ secrets.HEROKU_APP_NAME }}
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
settings.json
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ This section has moved here: [https://facebook.github.io/create-react-app/docs/t
build

`docker build -t <username>/<appname>:<tag> . `

`docker ps`

`docker images`


Expand Down Expand Up @@ -116,7 +118,16 @@ Here's how you can do it:
```bash
docker buildx build --platform linux/amd64 -t <username>/<appname>:<tag> . --load
```

This command tells Docker to build the image for the `linux/amd64` platform.

After building the image, you can push it to Heroku as before. Remember to tag the image correctly for Heroku before pushing it.
After building the image, you can push it to Heroku as before. Remember to tag the image correctly for Heroku before pushing it.

5. **Push and Deploy**

```
docker push registry.heroku.com/<appname>/web
```

```
heroku container:release web --app <appname>
```

0 comments on commit 6d269fa

Please sign in to comment.