-
Notifications
You must be signed in to change notification settings - Fork 5
81 lines (71 loc) · 2.29 KB
/
mc-costopti-costselector-ci.yaml
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: MC-CostOpti-CostSelector-CI (CI)
on:
push:
branches:
- main
- release
tags:
- "v*.*.*"
paths-ignore:
- ".github/**"
- "AlarmService/**"
- "assetCollector/**"
- "BackEnd/**"
- "cost-fe/**"
- "costCollector/**"
- "costProcessor/**"
- "mysql/**"
- "**.md"
- "LICENSE.txt"
- ".gitignore"
env:
DOCKER_REGISTRY_NAME: cloudbaristaorg
GHCR_REGISTRY_NAME: ${{ github.repository_owner }}
IMAGE_NAME: mc-costopti-costselector
jobs:
publish-container-image:
name: Publish a container image
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Extract metadata from Git reference and GitHub events
id: meta
uses: docker/metadata-action@v5
with:
images: |
# image name for Docker Hub
${{env.DOCKER_REGISTRY_NAME}}/${{env.IMAGE_NAME}}
# image name for GitHub Container Registry (GHCR)
ghcr.io/${{env.GHCR_REGISTRY_NAME}}/${{env.IMAGE_NAME}}
tags: |
type=semver,enable=true,pattern={{version}}
type=edge,enable=true,branch=main
type=ref,event=branch
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# TODO: Create a PAT with `read:packages` and `write:packages` scopes and save it as an Actions secret `CR_PAT`
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and publish
id: docker_build
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./costSelector
file: ./costSelector/Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}