Skip to content

Commit f562d39

Browse files
authored
Create main.yml
1 parent c364d51 commit f562d39

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
11+
jobs:
12+
push_to_registry:
13+
name: Push Docker image to Docker Hub
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: get_image_name
17+
run: |
18+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
19+
20+
# Use Docker `latest` tag convention
21+
[ "$VERSION" == "master" ] && VERSION=latest
22+
23+
repository=${{ github.repository }}
24+
IMAGE_NAME=${{ github.actor }}/${repository##*/}:$VERSION
25+
26+
echo IMAGE_NAME=$IMAGE_NAME
27+
28+
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
29+
- name: Check out the repo
30+
uses: actions/checkout@v2
31+
- name: Log in to Docker Hub
32+
uses: docker/login-action@v1
33+
with:
34+
username: ${{ secrets.DOCKER_USERNAME }}
35+
password: ${{ secrets.DOCKER_PASSWORD }}
36+
- name: Push to Docker Hub
37+
uses: docker/build-push-action@v2
38+
with:
39+
push: true
40+
tags: ${{ env.IMAGE_NAME }}

0 commit comments

Comments
 (0)