-
Notifications
You must be signed in to change notification settings - Fork 13
81 lines (71 loc) · 2.96 KB
/
Copy pathdocker.yml
File metadata and controls
81 lines (71 loc) · 2.96 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
name: Publish latest Docker images
on:
push:
release:
types:
- published
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
packages: write
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Set up QEMU
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Set Docker Image Tag
id: set_names
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]; then
DOCKER_IMAGE_TAG=$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g")
else
DOCKER_IMAGE_TAG="latest"
fi
DOCKER_IMAGE_NAME=ddapm-test-agent
DOCKER_IMAGE_NAME=$(echo ghcr.io/${GITHUB_REPOSITORY}/${DOCKER_IMAGE_NAME} | tr '[:upper:]' '[:lower:]')
DOCKER_IMAGE_NAME_WITH_TAG=$(echo ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} | tr '[:upper:]' '[:lower:]')
echo "Using image name '$DOCKER_IMAGE_NAME_WITH_TAG'"
echo "image_name=$DOCKER_IMAGE_NAME_WITH_TAG" >> $GITHUB_OUTPUT
- name: Login to Docker
run: docker login -u publisher -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Docker Build
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
with:
push: true
tags: ${{ steps.set_names.outputs.image_name }}
platforms: "linux/amd64,linux/arm64/v8"
context: .
build-and-publish-windows:
runs-on: windows-latest
permissions:
packages: write
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Set Docker Image Tag
id: set_names
shell: pwsh
run: |
if ("${{ startsWith(github.ref, 'refs/tags/') }}" -eq "true") {
$DOCKER_IMAGE_TAG = "${{ github.ref }}".Replace("refs/tags/", "") + "-windows"
} else {
$DOCKER_IMAGE_TAG = "latest-windows"
}
$DOCKER_IMAGE_NAME = "ddapm-test-agent"
$DOCKER_IMAGE_NAME = "ghcr.io/${{ github.repository }}/${DOCKER_IMAGE_NAME}".ToLower()
$DOCKER_IMAGE_NAME_WITH_TAG = "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}".ToLower()
Write-Host "Using image name '$DOCKER_IMAGE_NAME_WITH_TAG'"
"image_name=$DOCKER_IMAGE_NAME_WITH_TAG" >> $env:GITHUB_OUTPUT
- name: Login to Docker
run: docker login -u publisher -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Docker Build
shell: pwsh
run: |
docker build -t ${{ steps.set_names.outputs.image_name }} -f ./Dockerfile.windows .
docker push ${{ steps.set_names.outputs.image_name }}