-
Notifications
You must be signed in to change notification settings - Fork 179
149 lines (147 loc) · 6.5 KB
/
docker_bin.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
name: Docker Image
on:
workflow_dispatch:
inputs:
guild_deploy_branch:
description: Branch to deploy
required: false
default: master
testing:
description: Testing workflow
required: false
type: boolean
default: true
push:
paths:
- 'files/docker/node/release-versions/cardano-node-latest.txt'
- 'files/docker/node/release-versions/mithril-latest.txt'
jobs:
set_environment_vars:
runs-on: ubuntu-latest
outputs:
guild_deploy_branch: ${{ steps.set_guild_deploy_branch.outputs.guild_deploy_branch }}
g_account: ${{ steps.set_g_account.outputs.g_account }}
testing: ${{ steps.set_testing.outputs.testing }}
short_sha: ${{ steps.set_short_sha.outputs.short_sha }}
cnversion: ${{ steps.set_cnversion.outputs.cnversion }}
steps:
- name: Set branch name
id: vars
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Set GUILD_DEPLOY_BRANCH
id: set_guild_deploy_branch
run: |
echo "guild_deploy_branch=${{ (github.event_name == 'push' && steps.vars.outputs.branch) || github.event.inputs.guild_deploy_branch }}" >> $GITHUB_OUTPUT
- name: Set G_ACCOUNT
id: set_g_account
run: |
echo "g_account=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_OUTPUT
- name: Set TESTING
id: set_testing
run: |
echo "testing=${{ github.event_name == 'push' && (steps.vars.outputs.branch != 'master' || needs.set_environment_vars.outputs.guild_deploy_branch == 'docker-alpha') || github.event.inputs.testing }}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
ref: ${{ steps.set_guild_deploy_branch.outputs.guild_deploy_branch }}
- name: Get short SHA
id: set_short_sha
run: |
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Get CNVERSION
id: set_cnversion
run: |
echo "cnversion=$(cat files/docker/node/release-versions/cardano-node-latest.txt)" >> $GITHUB_OUTPUT
build_production:
needs: set_environment_vars
if: needs.set_environment_vars.outputs.testing == 'false' && (needs.set_environment_vars.outputs.guild_deploy_branch == 'master' || needs.set_environment_vars.outputs.guild_deploy_branch == 'docker-alpha')
env:
REGISTRY: docker.io
runs-on: ubuntu-latest
steps:
- name: Set IMAGE_TAGS
run: |
GUILD_DEPLOY_BRANCH=$(echo "${{ needs.set_environment_vars.outputs.guild_deploy_branch }}" | sed 's/\//_/g')
REGISTRY=${{ env.REGISTRY }}
REPO=${{ secrets.DOCKER_USER }}
REPO=${REPO,,}
IMAGE_NAME="$REGISTRY/$REPO/cardano-node"
CNVERSION=${{ needs.set_environment_vars.outputs.cnversion }}
IMAGE_TAGS="$IMAGE_NAME:latest,$IMAGE_NAME:$CNVERSION"
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_TAGS=$IMAGE_TAGS" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
ref: ${{ needs.set_environment_vars.outputs.guild_deploy_branch }}
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY}}
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push production container image
uses: docker/build-push-action@v5
with:
context: .
file: files/docker/node/dockerfile_bin
push: true
tags: ${{ env.IMAGE_TAGS }}
build-args: |
G_ACCOUNT=${{ needs.set_environment_vars.outputs.g_account }}
GUILD_DEPLOY_BRANCH=${{ needs.set_environment_vars.outputs.guild_deploy_branch }}
- name: Add summary details
if: always()
run: |
echo "## Summary Details" >> $GITHUB_STEP_SUMMARY
echo "* Image Name: ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
echo "* Image Tags: ${{ env.IMAGE_TAGS }}" >> $GITHUB_STEP_SUMMARY
echo "* G_ACCOUNT: ${{ needs.set_environment_vars.outputs.g_account }}" >> $GITHUB_STEP_SUMMARY
echo "* GUILD_DEPLOY_BRANCH: ${{ needs.set_environment_vars.outputs.guild_deploy_branch }}" >> $GITHUB_STEP_SUMMARY
echo "* REGISTRY: ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY
echo "* REGISTRY_USER: ${{ secrets.DOCKER_USER }}" >> $GITHUB_STEP_SUMMARY
build_testing:
needs: set_environment_vars
if: needs.set_environment_vars.outputs.testing == 'true' || needs.set_environment_vars.outputs.guild_deploy_branch != 'master'
env:
REGISTRY: ghcr.io
runs-on: ubuntu-latest
steps:
- name: Set IMAGE_TAGS
run: |
GUILD_DEPLOY_BRANCH=$(echo "${{ needs.set_environment_vars.outputs.guild_deploy_branch }}" | sed 's/\//_/g')
REGISTRY=${{ env.REGISTRY }}
REPO=${{ needs.set_environment_vars.outputs.g_account }}
IMAGE_NAME="$REGISTRY/$REPO/cardano-node"
CNVERSION=${{ needs.set_environment_vars.outputs.cnversion }}
SHA=${{ needs.set_environment_vars.outputs.short_sha }}
IMAGE_TAGS="$IMAGE_NAME:test,$IMAGE_NAME:$CNVERSION-$SHA,$IMAGE_NAME:$GUILD_DEPLOY_BRANCH-$SHA"
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_TAGS=$IMAGE_TAGS" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
ref: ${{ needs.set_environment_vars.outputs.guild_deploy_branch }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY}}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push testing container image
uses: docker/build-push-action@v5
with:
context: .
file: files/docker/node/dockerfile_bin
push: true
tags: ${{ env.IMAGE_TAGS }}
build-args: |
G_ACCOUNT=${{ needs.set_environment_vars.outputs.g_account }}
GUILD_DEPLOY_BRANCH=${{ needs.set_environment_vars.outputs.guild_deploy_branch }}
- name: Add summary details
if: always()
run: |
echo "## Summary Details" >> $GITHUB_STEP_SUMMARY
echo "* Image Name: ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
echo "* Image Tags: ${{ env.IMAGE_TAGS }}" >> $GITHUB_STEP_SUMMARY
echo "* G_ACCOUNT: ${{ needs.set_environment_vars.outputs.g_account }}" >> $GITHUB_STEP_SUMMARY
echo "* GUILD_DEPLOY_BRANCH: ${{ needs.set_environment_vars.outputs.guild_deploy_branch }}" >> $GITHUB_STEP_SUMMARY
echo "* REGISTRY: ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY
echo "* REGISTRY_USER: ${{ github.repository_owner }}" >> $GITHUB_STEP_SUMMARY