Skip to content

Instantly share code, notes, and snippets.

@hosni
Last active December 16, 2023 11:23
Show Gist options
  • Save hosni/c4972af11c121115bdea3c218dccbdd8 to your computer and use it in GitHub Desktop.
Save hosni/c4972af11c121115bdea3c218dccbdd8 to your computer and use it in GitHub Desktop.
name: Build Image
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Define your apps build steps here just before build image.
- name: Log into registry ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
file: ./Dockerfile
context: ./src/
build-args: TZ=Asia/Tehran
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment