-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (88 loc) · 3.06 KB
/
docker-release.yml
File metadata and controls
98 lines (88 loc) · 3.06 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
name: Docker Release
on:
release:
types:
- created
workflow_dispatch:
inputs:
release:
description: 'ex: @roll-stack/web-app-v1.0.0'
type: string
required: true
ref:
description: 'branch, tag or SHA'
type: string
jobs:
determine-changes:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
package: ${{ steps.set-package.outputs.package }}
version: ${{ steps.set-package.outputs.version }}
steps:
- name: Regex matching
uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ github.event.inputs.release || github.ref_name }}
regex: '@roll-stack\/([a-z-]+)-(v[0-9]+.[0-9]+.[0-9]+)'
- name: Set package in env
id: set-package
run: |
APPS=("web-app" "web-storefront" "web-parser" "atrium-telegram" "hub-telegram" "storefront-telegram" "core-telegram" "webinar")
MATCH="${{ steps.regex-match.outputs.match }}"
if [ -z "$MATCH" ]; then
echo "package=" >> $GITHUB_OUTPUT
echo "version=" >> $GITHUB_OUTPUT
else
found=false
for app in "${APPS[@]}"; do
if [ "$app" == "${{ steps.regex-match.outputs.group1 }}" ]; then
found=true
break
fi
done
if $found; then
echo "package=${{ steps.regex-match.outputs.group1 }}" >> $GITHUB_OUTPUT
echo "version=${{ steps.regex-match.outputs.group2 }}" >> $GITHUB_OUTPUT
else
echo "package=" >> $GITHUB_OUTPUT
echo "version=" >> $GITHUB_OUTPUT
fi
fi
- name: Result
run: |
echo "${{ steps.set-package.outputs.package }}"
echo "${{ steps.set-package.outputs.version }}"
build:
needs: determine-changes
if: ${{ needs.determine-changes.outputs.package != '' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.ref || github.ref_name }}
- name: Set APP in env
run: |
echo "APP_NAME=${{ needs.determine-changes.outputs.package }}" >> $GITHUB_ENV
echo "APP_VERSION=${{ needs.determine-changes.outputs.version }}" >> $GITHUB_ENV
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build ${{ env.APP_NAME }}
uses: docker/build-push-action@v6
with:
context: .
file: docker/${{ env.APP_NAME }}/Dockerfile
push: true
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
tags: ${{ secrets.DOCKER_REGISTRY }}/roll-stack/${{ env.APP_NAME }}:latest,${{ secrets.DOCKER_REGISTRY }}/roll-stack/${{ env.APP_NAME }}:${{ env.APP_VERSION }}