-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (73 loc) · 2.04 KB
/
ci.yml
File metadata and controls
88 lines (73 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: CI
on:
push:
branches: [main]
pull_request:
env:
APP_PORT: 80
APP_ENV: "testing"
jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.25'
- name: Run unit tests
run: go test ./...
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.25'
- name: Run go fmt
run: go fmt ./...
build:
needs: [test, format]
name: Build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
outputs:
tag: ${{ steps.image-name.outputs.TAG }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
- name: Generate Image Name
id: image-name
run: |
TAG=$(echo ${{ github.sha }} | cut -c1-7)
IMAGE_URL=$(echo ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:$TAG | tr '[:upper:]' '[:lower:]')
echo "IMAGE_URL=$IMAGE_URL" >> $GITHUB_OUTPUT
echo "TAG=$TAG" >> $GITHUB_OUTPUT
- name: Build and push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.image-name.outputs.IMAGE_URL }}
deploy:
if: github.event_name == 'push'
needs: build
name: Deploy
uses: wajeht/docker-cd-deploy-workflow/.github/workflows/deploy.yaml@v0.0.18
with:
app-path: apps/commit
tag: ${{ needs.build.outputs.tag }}
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}