-
Notifications
You must be signed in to change notification settings - Fork 55
41 lines (37 loc) · 1.24 KB
/
schema_tools.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
name: Schema File Tools Docker Image
on:
push:
tags: [ '**' ]
branches: [ main ]
pull_request:
branches: [ main ]
paths:
- .github/workflows/schema_tools.yml
- schemas/*
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build schemas/. -t build-tool-schemas
- name: Login to GitHub Package Registry
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push the Docker image
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: |
function tag_and_push {
docker tag build-tool-schemas "otel/build-tool-schemas:${1}" && docker push "otel/build-tool-schemas:${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