-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (38 loc) · 1.44 KB
/
cd.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
name: Deploy
on:
release:
types: [prereleased, released]
concurrency:
cancel-in-progress: false
env:
ENVIRONMENT: ${{ github.event.action == 'prereleased' && 'staging' || 'production' }}
jobs:
build-and-push:
name: "Build and push docker image"
runs-on: ubuntu-latest
environment: ${{ env.ENVIRONMENT }}
steps:
- name: Print variables
run: echo "${{ toJSON(vars)}}"
- name: Print env
run: echo "${{ toJSON(env)}}"
- name: Print secrets
run: echo "${{ toJSON(secrets)}}"
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image (environment)
run: |
docker build -t ghcr.io/killmenot/github-test-${{ env.ENVIRONMENT }}:${{ github.event.release.tag_name }} -f Dockerfile .
- name: Push docker image to GitHub Container Registry (environment)
run: |
docker push ghcr.io/killmenot/github-test-${{ env.ENVIRONMENT }}:${{ github.event.release.tag_name }}
- name: Push docker image to GitHub Container Registry (production > staging)
if: env.ENVIRONMENT == 'production'
run: |
docker push ghcr.io/killmenot/github-test-staging:${{ github.event.release.tag_name }}