mirror of
https://ak-git.vectorsigma.ru/terghalin/metalcheck.git
synced 2026-03-19 04:03:29 +09:00
64 lines
1.6 KiB
YAML
64 lines
1.6 KiB
YAML
name: CI Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
GH_REGISTRY: ghcr.io
|
|
LOCAL_REGISTRY: ${{ vars.LOCAL_REGISTRY }}
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: Build and Push Docker Image
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Determine Registry
|
|
id: registry
|
|
run: |
|
|
if [[ "${{ github.repository }}" == *github.com* ]]; then
|
|
echo "REGISTRY=${{ env.GH_REGISTRY }}" >> $GITHUB_ENV
|
|
else
|
|
echo "REGISTRY=${{ env.LOCAL_REGISTRY }}" >> $GITHUB_ENV
|
|
fi
|
|
shell: bash
|
|
|
|
- name: Debug Registry
|
|
run: |
|
|
echo "Registry is set to: $REGISTRY"
|
|
|
|
- name: Log in to Docker Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Cache Python dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Build and Push Docker Image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
push: true
|
|
tags: |
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|