-
Notifications
You must be signed in to change notification settings - Fork 242
54 lines (54 loc) · 2.13 KB
/
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: Publish Docker image
on:
workflow_dispatch:
push:
tags: ["v*"]
branches: [main]
pull_request:
env:
REGISTRY: msgraphprod.azurecr.io
IMAGE_NAME: public/openapi/hidi
PREVIEW_BRANCH: "refs/heads/main"
jobs:
push_to_registry:
environment:
name: acr
name: Push Docker image
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Login to registry
uses: docker/[email protected]
with:
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
registry: ${{ env.REGISTRY }}
- run: |
$content = [XML](Get-Content ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj)
$version = $content.Project.PropertyGroup.Version
echo "::set-output name=version::${version}"
shell: pwsh
id: getversion
- name: Get truncated run number
if: contains(github.ref, env.PREVIEW_BRANCH)
id: runnumber
run: echo "runnumber=$(echo ${{ github.run_number }} | awk '{ print substr($0, length($0)-3, length($0)) }')" >> $GITHUB_OUTPUT
- name: Get current date
if: contains(github.ref, env.PREVIEW_BRANCH)
id: date
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Push to registry - Nightly
if: contains(github.ref, env.PREVIEW_BRANCH)
uses: docker/[email protected]
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}-preview.${{ steps.date.outputs.date }}${{ steps.runnumber.outputs.runnumber }}
build-args: |
version_suffix=preview.${{ steps.date.outputs.date }}${{ steps.runnumber.outputs.runnumber }}
- name: Push to registry - Release
if: contains(github.ref, 'refs/tags/v')
uses: docker/[email protected]
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}