Files
workflows/.github/workflows/build.yaml
2024-12-26 16:00:05 +03:00

60 lines
2.0 KiB
YAML

on:
workflow_call:
inputs:
lfs:
type: boolean
default: false
tag:
type: string
required: false
default: latest
jobs:
build:
runs-on: gpu
env:
#DOCKER_HOST: tcp://${{ matrix.config.host }}:2376
CR_REGISTRY: crp8vh46gd976oq8ipla
CR_REPO: ${{ github.event.repository.name }}
INPUT_TAG: ${{ inputs.tag }}
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 image
run: |
docker build -t cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7} --ssh default .
- name: Yandex Cloud Login
uses: yc-actions/yc-cr-login@v2
with:
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
- name: Tag image
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
run: |
docker push cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7}
docker push cr.yandex/$CR_REGISTRY/$CR_REPO:${INPUT_TAG/\//-}