refactor: move images dir #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: releaser | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
paths-ignore: | ||
- README.md | ||
- .github/** | ||
- '!.github/workflows/**' | ||
paths: | ||
- server/** | ||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
jobs: | ||
build: | ||
defaults: | ||
run: | ||
working-directory: ./server | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Install cosign | ||
if: github.event_name != 'pull_request' | ||
uses: sigstore/cosign-installer@v3 | ||
with: | ||
cosign-release: 'v2.1.1' | ||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
# https://github.com/docker/login-action | ||
- name: Login to registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
# https://github.com/docker/metadata-action | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
labels: git_commit=${{ github.sha }} | ||
tags: | | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch | ||
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag | ||
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr | ||
- name: Cache Docker layers | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: ${{ runner.os }}-buildx- | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
context: server | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
# linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8 | ||
platforms: linux/amd64 | ||
build-args: | | ||
GIT_COMMIT=${{ github.sha }} | ||
GIT_BRANCH=${{ github.ref }} | ||
- name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |