-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (73 loc) · 2.48 KB
/
deploy-image.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
name: Deployment
on:
release:
types:
- released
workflow_dispatch:
inputs:
tag:
default: edge
required: true
description: Docker image tag
env:
IMAGE_NAME: myrotvorets/myrnews-tgbot
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- name: Normalize inputs
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "REF=${{ github.event.release.tag_name }}" >> "${GITHUB_ENV}"
echo "IMAGE_VERSION=${{ github.event.release.tag_name }}" >> "${GITHUB_ENV}"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo REF= >> "${GITHUB_ENV}"
echo "IMAGE_VERSION=${{ github.event.inputs.tag }}" >> "${GITHUB_ENV}"
else
echo "Unknown event: ${{ github.event_name }}"
exit 1
fi
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
ref: ${{ env.REF }}
- name: Prepare the files
uses: myrotvorets/composite-actions/prepare-k8s-deployment@master
with:
image_version: ${{ env.IMAGE_VERSION }}
secret_environment: ${{ secrets.SECRET_ENVIRONMENT }}
path: iac
- name: Start deployment
uses: chrnorm/deployment-action@d42cde7132fcec920de534fffc3be83794335c00 # v2.0.5
id: deployment
with:
token: "${{ github.token }}"
environment: production
- name: Deploy
uses: myrotvorets/kubectl-action@49846ef8e3f63df58b7def8a792bbc7407859dd4 # tag=2.0.1
with:
config: ${{ secrets.KUBE_CONFIG_DATA }}
version: 1.21
args: apply -k iac/
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@2afb7d27101260f4a764219439564d954d10b5b0 # tag=v2.0.1
with:
token: "${{ github.token }}"
state: "success"
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@2afb7d27101260f4a764219439564d954d10b5b0 # tag=v2.0.1
with:
token: "${{ github.token }}"
state: "failure"
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
- name: Cleanup
if: always()
run: rm -f ./iac/.env