-
Notifications
You must be signed in to change notification settings - Fork 19
114 lines (103 loc) · 4.5 KB
/
docker-env-build.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
name: Build Docker environment container
on:
workflow_dispatch:
push:
tags:
- "android*"
- "base*"
- "linux*"
- "emsdk*"
- "wine*"
- "winsdk*"
- "nssdk*"
- "ps4*"
- "ps5*"
env:
GOOGLE_ARTIFACT_REGISTRY: europe-west1-docker.pkg.dev
PUBLIC_REGISTRY: europe-west1-docker.pkg.dev/extender-426409/extender-public-registry
PRIVATE_REGISTRY_PS4: europe-west1-docker.pkg.dev/extender-426409/extender-ps4-private-registry
PRIVATE_REGISTRY_PS5: europe-west1-docker.pkg.dev/extender-426409/extender-ps5-private-registry
PRIVATE_REGISTRY_NINTENDO: europe-west1-docker.pkg.dev/extender-426409/extender-nintendo-private-registry
PRIVATE_PLATFORMS: "nssdk ps4 ps5"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Process tag name
id: name_postprocess
run: |
PRIVATE_PLATFORM_LIST="${{ env.PRIVATE_PLATFORMS }}"
PUBLIC_REGISTRY="${{ env.PUBLIC_REGISTRY }}"
PRIVATE_REGISTRY_PS4="${{ env.PRIVATE_REGISTRY_PS4 }}"
PRIVATE_REGISTRY_PS5="${{ env.PRIVATE_REGISTRY_PS5 }}"
PRIVATE_REGISTRY_NINTENDO="${{ env.PRIVATE_REGISTRY_NINTENDO }}"
SHORT_SHA="$(echo ${GITHUB_SHA} | cut -c1-8)"
TAG_NAME=${{ github.ref_name }}
DOCKERFILE="${TAG_NAME%%-*}"
PLATFORM="${DOCKERFILE%%.*}"
PLATFORM_VERSION=$(if [[ "$DOCKERFILE" == *"."* ]]; then echo "${DOCKERFILE#*.}"; else echo ""; fi)
IMAGE_VERSION="${TAG_NAME#*-}"
IMAGE_NAME=$(if [[ "$PLATFORM_VERSION" != "" ]]; then echo "$PLATFORM-$PLATFORM_VERSION"; else echo "$PLATFORM"; fi)
if [[ $PRIVATE_PLATFORM_LIST == *$PLATFORM* ]]; then
case $PLATFORM in
ps4)
TARGET_REGISTRY=$(echo $PRIVATE_REGISTRY_PS4)
;;
ps5)
TARGET_REGISTRY=$(echo $PRIVATE_REGISTRY_PS5)
;;
nssdk)
TARGET_REGISTRY=$(echo $PRIVATE_REGISTRY_NINTENDO)
;;
esac
else
TARGET_REGISTRY=$(echo $PUBLIC_REGISTRY)
fi
echo "TAG_NAME $TAG_NAME"
echo "DOCKERFILE $DOCKERFILE"
echo "PLATFORM $PLATFORM"
echo "PLATFORM_VERSION $PLATFORM_VERSION"
echo "IMAGE_VERSION $IMAGE_VERSION"
echo "IMAGE_NAME $IMAGE_NAME"
echo "TARGET_REGISTRY $TARGET_REGISTRY"
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "dockerfile=$DOCKERFILE" >> $GITHUB_OUTPUT
echo "platform=$PLATFORM" >> $GITHUB_OUTPUT
echo "platform_version=$PLATFORM_VERSION" >> $GITHUB_OUTPUT
echo "image_version=$IMAGE_VERSION" >> $GITHUB_OUTPUT
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "target_registry=$TARGET_REGISTRY" >> $GITHUB_OUTPUT
- name: Login to Google Artifact registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.GOOGLE_ARTIFACT_REGISTRY }}
username: _json_key
password: ${{ secrets.DOCKER_REGISTRY_JSON_KEY }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db
- name: Build and push
env:
DM_PACKAGES_URL: ${{ secrets.S3_URL }}
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85
with:
context: ${{ github.workspace }}/server/docker/
file: ${{ github.workspace }}/server/docker/Dockerfile.${{ steps.name_postprocess.outputs.dockerfile }}-env
pull: true
push: true
platforms: |
linux/amd64
secret-envs: |
DM_PACKAGES_URL=DM_PACKAGES_URL
tags: |
${{ steps.name_postprocess.outputs.target_registry }}/extender-${{ steps.name_postprocess.outputs.image_name }}-env:${{ steps.name_postprocess.outputs.image_version }}
${{ steps.name_postprocess.outputs.target_registry }}/extender-${{ steps.name_postprocess.outputs.image_name }}-env:${{ steps.name_postprocess.outputs.short_sha }}
${{ steps.name_postprocess.outputs.target_registry }}/extender-${{ steps.name_postprocess.outputs.image_name }}-env:latest
- name: Notify if tests failed
uses: homoluctus/slatify@master
if: failure()
with:
type: ${{ job.status }}
job_name: 'Extender: Docker environment container'
channel: '#defold-alarms-build'
url: ${{ secrets.SLACK_WEBHOOK }}