This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Dowload docker img and upload to Aliyun | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
types: [synchronize, opened, reopened, ready_for_review] | |
branches: | |
- "*" | |
workflow_dispatch: | |
inputs: | |
img: | |
description: "image to download, for instance, tensorflow/tensorflow" | |
required: true | |
compress: | |
description: "whether to compress the docker image, VM for github action has 14GB limit, if the image is too big, it is advised not to compress. set to 0 to skip compression" | |
default: "1" | |
required: false | |
ossPath: | |
default: "oss://oneflow-static/img" | |
required: false | |
description: "" | |
jobs: | |
downloadDockerImg: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- env: | |
IMG_NAME: ${{ github.event.inputs.img }} | |
COMPRESS: ${{ github.event.inputs.compress }} | |
OSSPATH: ${{ github.event.inputs.ossPath }} | |
OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }} | |
OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }} | |
run: | | |
echo ${{ contains(github.event.pull_request.labels.*.name, 'need-single-client-tests') }} | |
echo ${{ !contains(github.event.pull_request.labels.*.name, 'need-single-client-tests') }} | |
echo ${{ toJSON(github.event.pull_request.labels.*.name) }} | |
IMG_NAME=${IMG_NAME:-"busybox"} | |
COMPRESS=${COMPRESS:-"1"} | |
OSSPATH=${OSSPATH:-"oss://oneflow-static/img"} | |
echo "GITHUB_RUN_ID:${GITHUB_RUN_ID}" | |
set -x | |
set -o pipefail | |
python3 -m pip install pathvalidate | |
export sanitized_file=$(python3 sanitize_filename.py) | |
export tar_file=${sanitized_file}.tar | |
export gz_file=${tar_file}.gz | |
curl http://gosspublic.alicdn.com/ossutil/1.6.19/ossutil64 -o $HOME/ossutil64 | |
chmod 755 $HOME/ossutil64 | |
$HOME/ossutil64 config -e oss-cn-beijing.aliyuncs.com -i ${OSS_ACCESS_KEY_ID} -k ${OSS_ACCESS_KEY_SECRET} -L EN -c $HOME/.ossutilconfig | |
if [ "${COMPRESS}" = "1" ]; then | |
docker pull ${IMG_NAME} | |
docker save ${IMG_NAME} | gzip > ${gz_file} | |
$HOME/ossutil64 --update cp ${gz_file} ${OSSPATH}/${gz_file} | |
else | |
docker run --rm -v $PWD:$PWD -w $PWD ananace/skopeo copy docker://${IMG_NAME} dir:${sanitized_file} | |
echo "${IMG_NAME}" > ${sanitized_file}.tag | |
$HOME/ossutil64 --update cp --recursive ${sanitized_file} ${OSSPATH}/${sanitized_file} | |
$HOME/ossutil64 --update cp ${sanitized_file}.tag ${OSSPATH}/${sanitized_file}.tag | |
fi |