Skip to content

Commit

Permalink
ci: fix hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
hizkifw committed May 18, 2023
1 parent e8754dd commit cc2967b
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
name: Build and Push Docker Image

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-push:
docker:
runs-on: ubuntu-latest

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

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/hizkifw/gifthumb
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to GitHub Container Registry
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and tag Docker image
run: |
IMAGE_TAG=$(git rev-parse --short=7 HEAD)
BRANCH_NAME=${GITHUB_REF#refs/heads/}
DOCKER_REPO=ghcr.io/${{ github.repository }}
# Tag the image with commit hash and branch name
docker buildx build \
--file Dockerfile \
--tag $DOCKER_REPO:${IMAGE_TAG} \
--tag $DOCKER_REPO:${BRANCH_NAME} \
--tag $DOCKER_REPO:latest \
--push \
.
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit cc2967b

Please sign in to comment.