Skip to content

Commit

Permalink
Update main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
s83 authored Feb 14, 2024
1 parent 4a0b504 commit 7490977
Showing 1 changed file with 10 additions and 43 deletions.
53 changes: 10 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,29 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1

- name: Setup Docker Buildx
uses: docker-actions/setup-buildx-action@v1
with:
context: ${{ github.workspace }}
uses: docker/setup-buildx-action@v3.0.0

- name: Login to Docker Hub
uses: actions/docker/login@v2
uses: docker/login-action@v3.0.0
with:
registry: ${{ secrets.DOCKERHUB_USERNAME }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
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
uses: docker/build-push-action@v5.1.0
with:
context: ${{ github.workspace }}
registry: ${{ secrets.DOCKERHUB_USERNAME }}
tag: latest
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-actions/tag-image@v1
uses: docker/build-push-action@v5.1.0
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/', '') }}
push: true
tag: ${{ secrets.DOCKERHUB_USERNAME }}/brudi-rclone:${{ 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 }}


0 comments on commit 7490977

Please sign in to comment.