Skip to content

Commit

Permalink
Added CI workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
moonstar-x committed Nov 1, 2024
1 parent 02608e7 commit f011775
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/callable-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build Docker Image

on:
workflow_call:
inputs:
image_tag:
type: string
required: true
ghcr_username:
type: string
required: true
ghcr_image_name:
type: string
required: true
secrets:
ghcr_token:
required: true

jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest

steps:
- name: Checkout the Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker Layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.ghcr_username }}
password: ${{ secrets.ghcr_token }}

- name: Build & Push Docker Image
id: docker_build
uses: docker/build-push-action@v6
env:
GHCR_IMAGE: ghcr.io/${{ inputs.ghcr_image_name }}
with:
context: .
push: true
tags: |
${{ env.GHCR_IMAGE }}:${{ inputs.image_tag }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64/v8

- name: Image Digest
run: echo ${{ steps.docker_build.outputs.digest }}
17 changes: 17 additions & 0 deletions .github/workflows/on-push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: On Push (Main)

on:
push:
branches:
- main

jobs:
build:
name: Build Docker Image
uses: ./.github/workflows/callable-build.yml
with:
ghcr_username: ${{ github.actor }}
ghcr_image_name: ${{ github.repository }}
image_tag: latest
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit f011775

Please sign in to comment.