67 lines
2.2 KiB
YAML
67 lines
2.2 KiB
YAML
on:
|
|
workflow_call:
|
|
inputs:
|
|
lfs:
|
|
type: boolean
|
|
default: false
|
|
tag:
|
|
type: string
|
|
required: false
|
|
default: latest
|
|
force_build:
|
|
type: boolean
|
|
default: false
|
|
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: gpu
|
|
env:
|
|
CR_REGISTRY: crp8vh46gd976oq8ipla
|
|
CR_REPO: ${{ github.event.repository.name }}
|
|
IMAGE_TAG: ${{ github.sha }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@master
|
|
- name: Checkout LFS
|
|
if: ${{ inputs.lfs }}
|
|
run: |
|
|
UrlBase=$GITHUB_SERVER_URL; \
|
|
UrlLfsBase=$UrlBase/${{ github.repository }}.git/info/lfs/objects; \
|
|
Auth=`/usr/bin/git config --get --local http.$UrlBase/.extraheader`; \
|
|
/usr/bin/git config --local http.${UrlLfsBase}/batch.extraheader "$Auth"; \
|
|
/usr/bin/git config --local http.${UrlLfsBase}/.extraheader ''
|
|
|
|
git config --local lfs.transfer.maxretries 1
|
|
#git ls-remote
|
|
#git lfs fetch origin refs/heads/${{ github.head_ref || github.ref_name }}
|
|
git lfs checkout
|
|
- name: Use ssh key
|
|
uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.LIB_SSH_KEY }}
|
|
- name: Build Docker image
|
|
run: |
|
|
if [ "$NO_CACHE" == "true" ]; then
|
|
docker build -t cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7} --no-cache --ssh default .
|
|
else
|
|
docker build -t cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7} --ssh default .
|
|
fi
|
|
env:
|
|
NO_CACHE: ${{ inputs.force_build || 'false' }}
|
|
- name: Yandex Cloud Login
|
|
uses: yc-actions/yc-cr-login@v2
|
|
with:
|
|
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
|
|
- name: Tag image
|
|
env:
|
|
INPUT_TAG: ${{ inputs.tag }}
|
|
run: |
|
|
echo ${INPUT_TAG/\//-} ${IMAGE_TAG::7} $INPUT_TAG $IMAGE_TAG
|
|
docker tag cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7} cr.yandex/$CR_REGISTRY/$CR_REPO:${INPUT_TAG/\//-}
|
|
- name: Push image
|
|
env:
|
|
INPUT_TAG: ${{ inputs.tag }}
|
|
run: |
|
|
docker push cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7}
|
|
docker push cr.yandex/$CR_REGISTRY/$CR_REPO:${INPUT_TAG/\//-} |