mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-25 16:37:58 +03:00
92 lines
3.0 KiB
YAML
92 lines
3.0 KiB
YAML
name: Dev Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
paths:
|
|
- "Dockerfile.dev"
|
|
- ".github/workflows/dev-image.yml"
|
|
pull_request:
|
|
branches:
|
|
- "main"
|
|
paths:
|
|
- "Dockerfile.dev"
|
|
- ".github/workflows/dev-image.yml"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: "dev-image-${{ github.ref }}"
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Revision tag (YYYYMMDD-shortsha + full SHA aliases)
|
|
id: revision
|
|
run: |
|
|
set -eu
|
|
short=$(git rev-parse --short=7 HEAD)
|
|
d=$(TZ=UTC0 git log -1 --format=%cd --date=format:%Y%m%d HEAD)
|
|
echo "image_tag=${d}-${short}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Log in to GHCR
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
|
|
# `tachi-ci` = the minimal `base` stage. Used as the `container:` image
|
|
# for every workspace CI job. Kept small so the per-job image pull is
|
|
# cheap.
|
|
- name: Build and push tachi-ci (base stage)
|
|
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile.dev
|
|
target: base
|
|
push: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
|
|
tags: |
|
|
ghcr.io/zkldi/tachi-ci:main
|
|
ghcr.io/zkldi/tachi-ci:latest
|
|
ghcr.io/zkldi/tachi-ci:${{ steps.revision.outputs.image_tag }}
|
|
ghcr.io/zkldi/tachi-ci:${{ github.sha }}
|
|
cache-from: type=gha,scope=dev-image-base
|
|
cache-to: type=gha,mode=max,scope=dev-image-base
|
|
|
|
# `tachi-dev` = full devcontainer image (`dev` stage on top of `base`).
|
|
# Pulled by devs once and rebuilt rarely; CI never touches it.
|
|
- name: Build and push tachi-dev (dev stage)
|
|
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile.dev
|
|
target: dev
|
|
push: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
|
|
tags: |
|
|
ghcr.io/zkldi/tachi-dev:main
|
|
ghcr.io/zkldi/tachi-dev:latest
|
|
ghcr.io/zkldi/tachi-dev:${{ steps.revision.outputs.image_tag }}
|
|
ghcr.io/zkldi/tachi-dev:${{ github.sha }}
|
|
cache-from: |
|
|
type=gha,scope=dev-image-dev
|
|
type=gha,scope=dev-image-base
|
|
cache-to: type=gha,mode=max,scope=dev-image-dev
|