mirror of
https://github.com/s83/docker-brudi-rclone.git
synced 2024-11-30 16:05:34 +00:00
Update main.yml
This commit is contained in:
parent
451081cdfd
commit
99f8171fa8
82
.github/workflows/main.yml
vendored
82
.github/workflows/main.yml
vendored
@ -2,37 +2,73 @@ name: Build and Publish Docker Image
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [main]
|
||||||
- main
|
tag_push:
|
||||||
tags:
|
paths:
|
||||||
- 'v*' # Trigger on tags that start with 'v'
|
- '*/' # Include all tags in any directory
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-publish:
|
build-and-publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Setup Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker-actions/setup-buildx-action@v1
|
||||||
|
|
||||||
- name: Build Docker image
|
|
||||||
run: |
|
|
||||||
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
|
|
||||||
DOCKER_TAG=latest
|
|
||||||
else
|
|
||||||
DOCKER_TAG=${{ github.ref }}
|
|
||||||
fi
|
|
||||||
docker build -t sami/brudi-rclone:${DOCKER_TAG} .
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
with:
|
||||||
|
context: ${{ github.workspace }}
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: actions/docker/login@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build image
|
||||||
|
id: build
|
||||||
|
uses: docker-buildx-action@v1
|
||||||
|
with:
|
||||||
|
context: ${{ github.workspace }}
|
||||||
|
push: false
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
|
- name: Tag and publish image (main branch)
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
uses: docker-actions/push-image@v2
|
||||||
|
with:
|
||||||
|
context: ${{ github.workspace }}
|
||||||
|
registry: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
tag: latest
|
||||||
|
|
||||||
|
- name: Tag and publish image (git tags)
|
||||||
|
if: startsWith(github.event.ref, 'refs/tags/')
|
||||||
|
uses: docker-actions/tag-image@v1
|
||||||
|
with:
|
||||||
|
context: ${{ github.workspace }}
|
||||||
|
registry: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
image: ${{ steps.build.outputs.image }}
|
||||||
|
tag: ${{ github.event.ref.replace('refs/tags/', '') }}
|
||||||
|
|
||||||
|
- name: Publish tagged image
|
||||||
|
uses: docker-actions/push-image@v2
|
||||||
|
with:
|
||||||
|
context: ${{ github.workspace }}
|
||||||
|
registry: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
tag: ${{ github.event.ref.replace('refs/tags/', '') }}
|
||||||
|
|
||||||
|
- name: Set output image name
|
||||||
|
uses: actions/set-output@v1
|
||||||
|
with:
|
||||||
|
name: image_name
|
||||||
|
value: ${{ steps.build.outputs.image }}
|
||||||
|
|
||||||
|
- name: Save image to GitHub Container Registry (optional)
|
||||||
|
if: github.event.action == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
uses: actions/create-github-container-registry-image@v1
|
||||||
|
with:
|
||||||
|
name: sami/brudi-rclone
|
||||||
|
image: ${{ steps.build.outputs.image }}
|
||||||
|
|
||||||
- name: Push image to Docker Hub
|
|
||||||
run: |
|
|
||||||
docker push sami/brudi-rclone:${DOCKER_TAG}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user