mirror of
https://github.com/YuzuZensai/Crowdin-Localization-Tools.git
synced 2026-01-06 04:33:03 +00:00
55 lines
1.5 KiB
YAML
55 lines
1.5 KiB
YAML
name: Build Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'index.js'
|
|
- 'package.json'
|
|
- 'Dockerfile'
|
|
- '.github/workflows/docker-build.yml'
|
|
pull_request:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'index.js'
|
|
- 'package.json'
|
|
- 'Dockerfile'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Prepare repository variables
|
|
id: prep
|
|
run: |
|
|
echo "REPO_NAME=$(echo ${{ github.repository }} | tr '/' ' ' | awk '{print tolower($2)}')" >> $GITHUB_OUTPUT
|
|
echo "OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: |
|
|
ghcr.io/${{ steps.prep.outputs.OWNER }}/${{ steps.prep.outputs.REPO_NAME }}:latest
|
|
ghcr.io/${{ steps.prep.outputs.OWNER }}/${{ steps.prep.outputs.REPO_NAME }}:${{ github.sha }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|