-
Notifications
You must be signed in to change notification settings - Fork 27
54 lines (52 loc) · 1.7 KB
/
publish-docker.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
name: Weaver Docker Generator
on:
push:
tags: [ '**' ]
branches:
- main
pull_request:
branches:
- main
paths:
- .github/workflows/publish-docker.yml
- 'src/**'
- 'crates/**'
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . -t weaver && docker run --rm weaver --help
build-and-publish-docker:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . -t weaver
- name: Push the Docker image
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
function tag_and_push {
docker tag weaver "otel/weaver:${1}" && docker push "otel/weaver:${1}"
}
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
tag_and_push "latest"
elif [[ "${GITHUB_REF}" =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
TAG="${GITHUB_REF#"refs/tags/v"}"
tag_and_push "${TAG}"
else
tag_and_push "${GITHUB_REF#"refs/tags/"}"
fi
- name: Push the Dev Docker image
if: startsWith(github.ref, 'refs/heads/feature/')
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
function tag_and_push {
docker tag weaver "otel/weaver:${1}" && docker push "otel/weaver:${1}"
}
TAG="${GITHUB_REF#"refs/heads/"}"
TAG="${TAG/"/"/"-"}"
tag_and_push "${TAG}"