Skip to content

fix working dir.

fix working dir. #43

name: Upload Python Package
on:
push:
release:
types: [published]
env:
REGISTRY: ghcr.io
DOCKER_REGISTRY: docker.io
DOCKER_REGISTRY_USER: sohma440
# IMAGE_NAME: sohma400/onnx2tf
# DOCKER_REGISTRY_USER: pinto0309
IMAGE_NAME: ${{ github.repository }}
jobs:
# pypi-deploy:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.x'
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install setuptools wheel pipenv
# - name: Build
# run: |
# python setup.py sdist bdist_wheel
# - name: Publish a Python distribution to PyPI
# uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
docker-deploy:
runs-on: ubuntu-latest
# todo
# needs: pypi-deploy
permissions:
contents: read
packages: write
strategy:
fail-fast: false # do not cancel even if any platform fails.
matrix:
# todo:
# platform: [linux/amd64,linux/arm64]
platform: [linux/amd64]
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Enable buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "GCR_REPO=$REGISTRY/${IMAGE_NAME,,}" >> $GITHUB_ENV
# echo "DH_REPO="$DOCKER_REGISTRY/${IMAGE_NAME,,} >> $GITHUB_ENV
echo "DH_REPO="$DOCKER_REGISTRY/sohma440/onnx2tf >> $GITHUB_ENV
- name: Log in to GCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DH_ACCESS_TOKEN }}
- name: Extract metadata (tags, labels) for GCR
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.GCR_REPO }} # GCR
${{ env.DH_REPO }} # Docker Hub
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
push: true
labels: ${{ steps.meta.outputs.labels }}
outputs: |
type=image,name=${{ env.GCR_REPO }},push-by-digest=true,name-canonical=true,push=true
type=image,name=${{ env.DH_REPO }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
retention-days: 1
merge:
runs-on: ubuntu-latest
needs:
- docker-deploy
steps:
- name: Prepare
run: |
echo "GCR_REPO=$REGISTRY/${IMAGE_NAME,,}" >> $GITHUB_ENV
# echo "DH_REPO="$DOCKER_REGISTRY/${IMAGE_NAME,,} >> $GITHUB_ENV
echo "DH_REPO="$DOCKER_REGISTRY/sohma440/onnx2tf >> $GITHUB_ENV
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# For Github Container Registory
- name: Log in to GCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DH_ACCESS_TOKEN }}
- name: Extract metadata (tags, labels) for GCR
id: meta_gh
uses: docker/metadata-action@v5
with:
images: |
${{ env.GCR_REPO }}
${{ env.DH_REPO }}
- name: Create manifest list and push to GCR
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.GCR_REPO }}@sha256:%s ' *)
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DH_REPO }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.GCR_REPO }}:${{ steps.meta_gh.outputs.version }}
docker buildx imagetools inspect ${{ env.DH_REPO }}:${{ steps.meta_gh.outputs.version }}