-
Notifications
You must be signed in to change notification settings - Fork 15
47 lines (42 loc) · 1.75 KB
/
docker-ci.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
#*********************************************************************
# Copyright (c) Intel Corporation 2021
# SPDX-License-Identifier: Apache-2.0
#*********************************************************************/
name: Docker Image CI
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Build the Docker image
run: docker build -f "Dockerfile" --tag vprodemo.azurecr.io/rpc-go:${{ github.sha }} --tag vprodemo.azurecr.io/rpc-go:latest .
- name: Docker Login
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: vprodemo.azurecr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
logout: true
- name: Push the Docker image to the registry
if: ${{ github.ref == 'refs/heads/main' }}
run: docker push vprodemo.azurecr.io/rpc-go:${{ github.sha }}
- name: Push the Docker image to the registry
if: ${{ github.ref == 'refs/heads/main' }}
run: docker push vprodemo.azurecr.io/rpc-go:latest
- name: Push the Docker image to the registry
if: startsWith(github.ref, 'refs/tags/v')
run: docker image tag vprodemo.azurecr.io/rpc-go:${GITHUB_REF#refs/tags/} && docker push vprodemo.azurecr.io/rpc-go:${GITHUB_REF#refs/tags/}