-
Notifications
You must be signed in to change notification settings - Fork 59
73 lines (60 loc) · 2.6 KB
/
image.yml
File metadata and controls
73 lines (60 loc) · 2.6 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
name: Push Docker Image
run-name: PushI Docker Image by @${{ github.actor }}
on:
workflow_dispatch:
release:
types:
- published
permissions:
packages: write
# ------------------------------------------------------------------------------------------------------------------------
env:
ACR_NAME: 'ghcr.io'
ACR_APP_NAME: 'aik8s_troubleshoot'
# ------------------------------------------------------------------------------------------------------------------------
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
- name: Get repo name
id: set-repo
run: echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_OUTPUT
# Uses the `docker/login-action` action to log in to the Container registry using the account and password that
# will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
with:
registry: ${{ env.ACR_NAME }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set image name
id: image-name
run: |
echo "IMAGE_NAME_NO_TAG=${{ github.repository_owner }}/${{ steps.set-repo.outputs.REPO_NAME }}/${{ env.ACR_APP_NAME }}" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.ACR_NAME }}/${{ steps.image-name.outputs.IMAGE_NAME_NO_TAG }}
labels: |
org.opencontainers.image.title=aik8s_troubleshoot
org.opencontainers.image.description=Troubleshooting image for Microsoft Application Insights for Kubernetes
org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/${{ steps.set-repo.outputs.REPO_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build Docker image
run: docker build -t ${{ env.ACR_APP_NAME }} .
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}