-
Notifications
You must be signed in to change notification settings - Fork 8
42 lines (40 loc) · 1.21 KB
/
publish_docker_hub.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
---
name: 🐳 Docker Image CI
on: # yamllint disable-line rule:truthy
pull_request:
branches: [main]
tags: '*.*.*'
types: [closed]
jobs:
build_and_publish_on_docker_hub:
name: 🐳 Push Docker image to Docker Hub
if: github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Prepare tags
id: prep
run: |
DOCKER_IMAGE=optnc/yamlfixer
VERSION=noop
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:stable,${DOCKER_IMAGE}:${VERSION}"
else
TAGS="${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=tags::${TAGS}
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{secrets.OPT_DOCKERHUB_LOGIN}}
password: ${{secrets.OPT_DOCKERHUB_PASSWORD}}
- name: Build and push
id: docker_build
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.prep.outputs.tags }}