Update main.yml

This commit is contained in:
sᴧᴍᴜᴇʟ ᴍ 2024-02-15 01:05:32 +00:00 committed by GitHub
parent f61fd50162
commit b93344b046
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,41 +1,44 @@
name: Build and Publish Docker Image
name: ci
on:
push:
branches:
- main
- "**"
tags:
- 'v*' # Trigger on tags that start with 'v'
- "v*.*.*"
jobs:
build-and-publish:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.1
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
- name: Login to Docker Hub
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tag and publish image (main branch)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5.1.0
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/brudi-rclone:latest
- name: Tag and publish image (git tags)
if: startsWith(github.event.ref, 'refs/tags/')
uses: docker/build-push-action@v5.1.0
with:
push: true
tag: ${{ secrets.DOCKERHUB_USERNAME }}/brudi-rclone:${{ github.ref_name }}
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ secrets.DOCKERHUB_USERNAME }}/brudi-rclone
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}