-
Notifications
You must be signed in to change notification settings - Fork 3
82 lines (68 loc) · 2.62 KB
/
builds.yml
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
# env:
# DOCKER_REGISTRY: docker.io
# DAEMON_IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/obzev0-grpc-daemon
# CONTROLLER_IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/obzev0-k8s-controller
name: Docker CI/CD Pipeline
on:
push:
branches: [staging, release]
pull_request:
branches: [dev, staging, release]
env:
DOCKER_REGISTRY: docker.io
DAEMON_IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/obzev0-grpc-daemon
CONTROLLER_IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/obzev0-k8s-controller
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: echo "Running tests..." # Replace with actual test command
build-and-push-staging:
needs: test
if: github.ref == 'refs/heads/staging'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Daemon Docker image
run: |
make build-daemon TAG=${{ github.sha }}
make push-daemon TAG=${{ github.sha }}
docker tag ${{ env.DAEMON_IMAGE_NAME }}:${{ github.sha }} ${{ env.DAEMON_IMAGE_NAME }}:staging
docker push ${{ env.DAEMON_IMAGE_NAME }}:staging
create-release:
needs: build-and-push-staging
if: github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull and tag staging image for release
run: |
docker pull ${{ env.DAEMON_IMAGE_NAME }}:staging
docker tag ${{ env.DAEMON_IMAGE_NAME }}:staging ${{ env.DAEMON_IMAGE_NAME }}:v${{ github.run_number }}
docker push ${{ env.DAEMON_IMAGE_NAME }}:v${{ github.run_number }}
docker tag ${{ env.DAEMON_IMAGE_NAME }}:v${{ github.run_number }} ${{ env.DAEMON_IMAGE_NAME }}:latest
docker push ${{ env.DAEMON_IMAGE_NAME }}:latest
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Release ${{ github.run_number }}
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false