-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (148 loc) · 4.76 KB
/
build-deploy.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Docker Image CI
on:
push:
tags:
- "v*.*.*"
env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
DEPLOY_NAME: demo
jobs:
buildImage:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create GitHub Release
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
TAG=${{ github.ref }}
VERSION=${TAG#refs/tags/}
gh release create $VERSION -t $VERSION -n "Release notes for $VERSION"
# helmTest:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
#
# - name: Install Helm
# run: |
# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
# chmod 700 get_helm.sh
# ./get_helm.sh
#
# - name: Lint Helm Chart
# run: |
# helm lint --values ./deployment/$DEPLOY_NAME/values.yaml ./deployment/$DEPLOY_NAME
#
# helmRelease:
# needs: [ helmTest ]
# runs-on: ubuntu-latest
# permissions:
# contents: write
# pull-requests: write
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
#
# - name: Configure Git
# run: |
# git config user.name "$GITHUB_ACTOR"
# git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
#
# - name: Install Helm
# uses: azure/setup-helm@v1
# with:
# version: v3.8.1
#
# - name: custom packaging
# run: |
# VERSION=${{github.ref_name}}
# rm -rf .cr-release-packages
# mkdir -p .cr-release-packages
# helm package deployment/$DEPLOY_NAME --app-version=${VERSION:1} --version=${VERSION:1} --destination=.cr-release-packages
#
# - name: Run chart-releaser
# # switch back to helm/chart-releaser-action if this contribution is ever mergedd
# uses: askcloudarchitech/chart-releaser-action@skip-packaging-option
# with:
# skip_packaging: true
# env:
# CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
#
# - name: Create GitHub Release
# env:
# GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# run: |
# TAG=${{ github.ref }}
# VERSION=${TAG#refs/tags/}
# gh release create $VERSION -t $VERSION -n "Release notes for $VERSION"
# deploy:
# needs: [ buildImage ]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
#
# - name: Install ArgoCD CLI if not exists
# run: |
# if ! command -v argocd &> /dev/null; then
# curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
# chmod +x /usr/local/bin/argocd
# fi
#
# - name: Deploy Application Dry Run
# env:
# ARGOCD_SERVER: ${{ secrets.ARGOCD_SERVER }}
# ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_AUTH_TOKEN }}
# run: |
# argocd app create $DEPLOY_NAME \
# --repo https://pixelaw.github.io/core/ \
# --path deployment/ \
# --revision ${VERSION:1} \
# --helm-chart $DEPLOY_NAME \
# --dest-namespace $DEPLOY_NAME-main \
# --dest-server https://kubernetes.default.svc \
# --helm-set-string dockerImage=$REGISTRY/pixelaw-core:${VERSION} \
# --upsert \
# --server $ARGOCD_SERVER \
# --auth-token $ARGOCD_AUTH_TOKEN
# argocd app sync $DEPLOY_NAME
# argocd app wait $DEPLOY_NAME