Skip to content

Commit

Permalink
Create main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostry authored Jun 20, 2024
1 parent a87ee0b commit 8f42cc5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Docker image

on:
push:
branches:
- master
release:
types: [published]
workflow_dispatch:

jobs:
push_to_registry:
runs-on: ubuntu-latest
steps:
- name: get_image_name
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
repository=${{ github.repository }}
IMAGE_NAME=${{ github.actor }}/${repository##*/}
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check out the repo
uses: actions/checkout@v2
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
tags: "${{ env.IMAGE_NAME }}:${{ env.VERSION }}"

0 comments on commit 8f42cc5

Please sign in to comment.