-
Notifications
You must be signed in to change notification settings - Fork 9
89 lines (75 loc) · 2.84 KB
/
deploy-production.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
---
# Inspired by: https://github.com/github/super-linter/blob/main/.github/workflows/deploy-production.yml
name: Deploy Production
on:
push:
branches: [ main ]
env:
REGISTRY: ghcr.io
permissions:
contents: read
jobs:
build:
name: Deploy Docker Image - Development
runs-on: ubuntu-latest
permissions:
deployments: write
packages: write
strategy:
fail-fast: false
matrix:
images:
- container-image-id-prefix: ""
deployment-environment-identifier: Production
image-id: production
timeout-minutes: 60
steps:
- name: Repository checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
with:
fetch-depth: 0
- name: Get current date
run: |
echo "Appending the build date contents to GITHUB_ENV..."
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "${GITHUB_ENV}"
- name: Setup BuildX
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55
- name: Login to GitHub Container Registry
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Start deployment
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: bobheadxi/deployments@88ce5600046c82542f8246ac287d0a53c461bca3
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ matrix.images.deployment-environment-identifier }}
- name: Build Docker image - ${{ matrix.images.image-id }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
with:
context: .
file: ./Dockerfile
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=${{ github.sha }}
load: false
push: true
tags: |
${{env.REGISTRY }}/${{ github.repository }}:${{ matrix.images.container-image-id-prefix }}latest
- name: Update deployment status
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: bobheadxi/deployments@88ce5600046c82542f8246ac287d0a53c461bca3
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ steps.deployment.outputs.env }}
env_url: https://github.com/${{ github.repository }}