Skip to content

Commit

Permalink
Create workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekweb2013 committed May 25, 2022
1 parent 3060526 commit e2653ae
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build

on:
push:
branches:
- main

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: setup go
uses: actions/setup-go@v2
with:
go-version: ^1.18

- name: login to github docker registry
uses: docker/login-action@v1.14.1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: publish docker image to registry
env:
COMMIT_SHA: ${{ github.sha }}
REPO_REGISTRY: ghcr.io/${{ github.repository_owner }}/batnoter
run: |
docker build \
-t $REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/} \
-t $REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:$COMMIT_SHA \
-t $REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:latest .
docker push -a $REPO_REGISTRY/${GITHUB_REPOSITORY#*/}
38 changes: 38 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy

on:
push:
branches:
- main

jobs:

deploy:
runs-on: ubuntu-latest
environment:
name: Production
url: 'https://batnoter.com'

steps:
- uses: actions/checkout@v2

- name: setup go
uses: actions/setup-go@v2
with:
go-version: ^1.18

- name: login to heroku docker registry
uses: docker/login-action@v1.14.1
with:
registry: registry.heroku.com
username: ${{ github.repository_owner }}
password: ${{ secrets.HEROKU_API_KEY }}

- name: deploy to heroku
env:
HEROKU_APP_NAME: batnoter
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
heroku container:push web -a $HEROKU_APP_NAME
heroku container:release web -a $HEROKU_APP_NAME
heroku releases --json -n 1 -a $HEROKU_APP_NAME | grep '"succeeded"'
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test

on:
push:
pull_request:
types: [opened, synchronize, reopened]
# Note: GitHub does not pass secrets(for security reasons) to PR workflows created with forked repos
# So do not use any actions that require secrets
# Tee GITHUB_TOKEN secret is allowed with readonly access for PR workflows created with forked repos

jobs:

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: setup go
uses: actions/setup-go@v2
with:
go-version: ^1.18

- name: run tests
run: go test -v -race -coverprofile=coverage.out -coverpkg=./internal/... -covermode=atomic ./internal/...

- name: upload coverage to codecov
uses: codecov/codecov-action@v2

0 comments on commit e2653ae

Please sign in to comment.