-
Notifications
You must be signed in to change notification settings - Fork 3
141 lines (121 loc) · 4.79 KB
/
Copy pathdocker-build-push.yml
File metadata and controls
141 lines (121 loc) · 4.79 KB
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
name: Docker Build and Push to CR
on:
workflow_dispatch:
inputs:
GIT_REPO_FULL_NAME:
description: Select RepoName
required: false
type: choice
options:
- ohdsi/trex
- data2evidence/trex
GIT_BRANCH_NAME:
default: develop
description: Enter BranchName / ReleaseTagName
required: true
type: string
tag:
description: Enter tag for Image
required: true
type: string
push:
branches:
- develop
pull_request:
types: [opened, ready_for_review, reopened, synchronize]
env:
GIT_BRANCH_NAME: ${{ github.event.inputs.GIT_BRANCH_NAME || github.head_ref || github.ref_name }} # workflow_dispatch || pull_request || push
GIT_REPO_FULL_NAME: ${{ github.event.inputs.GIT_REPO_FULL_NAME || github.event.pull_request.head.repo.full_name || github.event.repository.full_name }} # workflow_dispatch || pull_request || push
jobs:
build-push-image:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- AZ_REGISTRY_REPOSITORY: d2e-trex-base
context: .
dockerfile: ./Dockerfile.trex
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
- name: Check out repository code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_BRANCH_NAME }}
repository: ${{ env.GIT_REPO_FULL_NAME }}
- name: Setting up variables
id: setup
run: |
DOCKER_BUILD_PUSH_BOOL_STR=false
if [[ ${{ github.event_name }} == "push" || ${{ github.event_name }} == "workflow_dispatch" ]]; then
DOCKER_BUILD_PUSH_BOOL_STR=true
fi
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
DOCKER_IMG_TAG_NAME=${{ github.event.inputs.tag }}
elif [[ ${{ github.event_name }} == "push" ]]; then
DOCKER_IMG_TAG_NAME=${{ github.ref_name }}
else
DOCKER_IMG_TAG_NAME=$(echo $(git rev-parse --short HEAD))
fi
echo GIT_BRANCH_NAME=$GIT_BRANCH_NAME >> $GITHUB_OUTPUT
echo DOCKER_IMG_TAG_NAME=$DOCKER_IMG_TAG_NAME >> $GITHUB_OUTPUT
echo DOCKER_BUILD_PUSH_BOOL_STR="${DOCKER_BUILD_PUSH_BOOL_STR}" >> $GITHUB_OUTPUT
REPO_OWNER="${{ github.repository_owner }}"
echo REPO_OWNER_LOWER=${REPO_OWNER,,} >> $GITHUB_OUTPUT
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Build and Push
id: build-push2
uses: docker/build-push-action@v6
with:
push: ${{ steps.setup.outputs.DOCKER_BUILD_PUSH_BOOL_STR }}
platforms: "linux/amd64"
tags: ghcr.io/${{ steps.setup.outputs.REPO_OWNER_LOWER }}/${{ matrix.AZ_REGISTRY_REPOSITORY }}:${{ steps.setup.outputs.DOCKER_IMG_TAG_NAME }}
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
# - name: delete-untagged-images
# if: env.GIT_BRANCH_NAME == 'develop'
# continue-on-error: true
# uses: actions/delete-package-versions@v5
# with:
# package-name: "d2e-trex-base"
# package-type: "container"
# min-versions-to-keep: 3
# delete-only-untagged-versions: "true"
- name: npm install
run: npm install
#- name: Generate dotenv
# run: npm run init:d2e
#- name: DC up
# run: npm run start:d2e
#- name: stop
# if: success() || failure()
# run: npm run stop:d2e
#- name: logs
# if: success() || failure()
# run: npm run logs:d2e
- name: Output Summary
run: |
echo "### Output summary 🚀" >> $GITHUB_STEP_SUMMARY
echo "Job Status: ${{ job.status }} " >> $GITHUB_STEP_SUMMARY
echo "GIT_BRANCH_NAME: ${{ env.GIT_BRANCH_NAME }} " >> $GITHUB_STEP_SUMMARY
echo "GIT_COMMIT_ARG: ${{ github.sha }} " >> $GITHUB_STEP_SUMMARY
echo "AZ_REGISTRY_REPOSITORY: ${{ matrix.AZ_REGISTRY_REPOSITORY }} " >> $GITHUB_STEP_SUMMARY
echo "DOCKER_BUILD_PUSH_BOOL_STR: ${{ steps.setup.outputs.DOCKER_BUILD_PUSH_BOOL_STR }} " >> $GITHUB_STEP_SUMMARY
echo "DOCKER_IMG_TAG_NAME: ${{ steps.setup.outputs.DOCKER_IMG_TAG_NAME }} " >> $GITHUB_STEP_SUMMARY