-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (78 loc) · 2.65 KB
/
pipeline.yaml
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: Build And Deploy
on:
push:
branches:
- "main"
jobs:
build:
name: Build
runs-on: ubuntu-20.04
outputs:
tag: ${{ steps.prep.outputs.tag }}
steps:
- uses: actions/checkout@v2
- id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="${{ secrets.REGISTRY_URL }}/abraham-ai/mars-${{ secrets.ENV }}"
echo ::set-output name=tagged_image::${IMAGE}:${TAG}
echo ::set-output name=tag::${TAG}
echo ::set-output name=image::${IMAGE}
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver: docker
- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.prep.outputs.tagged_image }},${{ steps.prep.outputs.image }}:latest
deploy:
name: Deploy
runs-on: ubuntu-20.04
needs: [build]
if: ${{ always() && (needs.build.result == 'success') }}
steps:
- name: Check out releases repo
uses: actions/checkout@v2
with:
repository: abraham-ai/releases
ref: main
token: ${{ secrets.GENEKOGAN_PAT }}
- id: prep
run: |
IMAGE="${{ secrets.REGISTRY_URL }}/abraham-ai/mars-${{ secrets.ENV }}"
TAG="${{needs.build.outputs.tag}}"
echo ::set-output name=tagged_image::${IMAGE}:${TAG}
echo ::set-output name=tag::${TAG}
echo ::set-output name=image::${IMAGE}
- name: Bump Env
uses: fjogeleit/yaml-update-action@main
with:
valueFile: "apps/mars/runner/values.yaml"
updateFile: true
propertyPath: "$.image"
value: ${{ steps.prep.outputs.tagged_image }}
repository: abraham-ai/releases
branch: main
targetBranch: main
masterBranchName: main
commitChange: true
createPR: false
message: "Update ${{ secrets.ENV }} Image Version to ${{ steps.prep.outputs.tagged_image }}"
token: ${{ secrets.GENEKOGAN_PAT }}
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "${{ secrets.ENV }} image ${{ steps.prep.outputs.tagged_image }} has been deployed."