-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (41 loc) · 1.43 KB
/
docker-image.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
name: Docker Image
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Log in to Docker registry
uses: docker/[email protected]
with:
registry: ${{ secrets.REGISTRY_HOST }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- name: Generate image name
id: reponame
uses: ashley-taylor/[email protected]
with:
value: ${{ github.repository }}
regex: /|-|_
flags: g
replacement: _
- name: Show image name
run: echo "${{ steps.reponame.outputs.value }}"
- name: Build and tag Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: false
tags: ${{ secrets.REGISTRY_HOST }}/${{ steps.reponame.outputs.value }}:latest, ${{ secrets.REGISTRY_HOST }}/${{ steps.reponame.outputs.value }}:${{ github.run_number }}
- name: Push Docker image to registry
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: ${{ secrets.REGISTRY_HOST }}/${{ steps.reponame.outputs.value }}:latest, ${{ secrets.REGISTRY_HOST }}/${{ steps.reponame.outputs.value }}:${{ github.run_number }}