Skip to content

Commit d76464b

Browse files
committed
Add initial Github Actions example with build and deploy
0 parents  commit d76464b

7 files changed

Lines changed: 106 additions & 0 deletions

File tree

.github/deploybot.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Deploybot config
2+
deployments:
3+
- name: development
4+
5+
- name: staging
6+
7+
- name: production
8+
# require manual deploy

.github/workflows/deploy.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: deploy
2+
on:
3+
deployment
4+
permissions:
5+
contents: read
6+
deployments: write
7+
jobs:
8+
deploy:
9+
name: deploy
10+
runs-on: ubuntu-latest
11+
env:
12+
SHA: ${{ github.event.deployment.sha }}
13+
ENVIRONMENT: ${{ github.event.deployment.environment }}
14+
DEPLOY_ID: ${{ github.event.deployment.id}}
15+
steps:
16+
- name: In-progress Status
17+
uses: chrnorm/deployment-status@v2
18+
with:
19+
token: '${{ github.token }}'
20+
state: 'in_progress'
21+
deployment-id: ${{env.DEPLOY_ID}}
22+
23+
- name: "Checkout"
24+
uses: "actions/checkout@v3"
25+
26+
- name: "Deploy ${{env.ENVIRONMENT}}"
27+
run: |
28+
echo "Deploying ${SHA} to ${ENVIRONMENT} environment"
29+
# Perform deploy (whatever that means to you) here
30+
31+
- name: Success Status
32+
if: success()
33+
uses: chrnorm/deployment-status@v2
34+
with:
35+
token: '${{ github.token }}'
36+
state: 'success'
37+
deployment-id: ${{env.DEPLOY_ID}}
38+
39+
- name: Failure Status
40+
if: failure()
41+
uses: chrnorm/deployment-status@v2
42+
with:
43+
token: '${{ github.token }}'
44+
state: 'failure'
45+
deployment-id: ${{env.DEPLOY_ID}}

.github/workflows/test.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
build:
9+
name: go
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
go: ['1.17', '1.18']
15+
steps:
16+
- name: setup
17+
uses: actions/setup-go@v3
18+
with:
19+
go-version: ${{matrix.go}}
20+
21+
- name: checkout
22+
uses: actions/checkout@v3
23+
24+
- name: test
25+
run: go test .

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Deploybot Github Actions Example
2+
3+
`github-actions-example` shows how to use [Deploybot](https://deploybot.app) with Github Actions.

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/deploybot/github-actions-example
2+
3+
go 1.18

main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package main
2+
3+
import "log"
4+
5+
func main() {
6+
log.Println(getMessage())
7+
}
8+
9+
func getMessage() string {
10+
return "Welcome to deploybot with GitHub Actions!"
11+
}

main_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package main
2+
3+
import "testing"
4+
5+
func TestGreeting(t *testing.T) {
6+
msg := getMessage()
7+
expected := "Welcome to deploybot with GitHub Actions!"
8+
if msg != expected {
9+
t.Errorf("expected %v, got %v", expected, msg)
10+
}
11+
}

0 commit comments

Comments
 (0)