-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,57 @@ | ||
name: Pull docker image | ||
name: Binary upload action | ||
|
||
description: pull a specific docker image | ||
|
||
inputs: | ||
docker-image: | ||
description: the image to pull | ||
required: true | ||
docker-registry: | ||
description: The registry to store the image after it is built. | ||
default: 308535385114.dkr.ecr.us-east-1.amazonaws.com | ||
repository: | ||
description: 'Repository to checkout, defaults to ""' | ||
default: '' | ||
type: string | ||
trigger-event: | ||
description: "Trigger Event in caller that determines whether or not to upload" | ||
type: string | ||
default: '' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Pull Docker image | ||
shell: bash | ||
env: | ||
DOCKER_IMAGE: ${{ inputs.docker-image }} | ||
DOCKER_REGISTRY: ${{ inputs.docker-registry }} | ||
run: | | ||
set -x | ||
set +e | ||
login() { | ||
aws ecr get-login-password --region us-east-1 | docker login -u AWS --password-stdin "$1" | ||
} | ||
retry () { | ||
$* || (sleep 1 && $*) || (sleep 2 && $*) | ||
} | ||
retry login "${DOCKER_REGISTRY}" | ||
set -e | ||
# ignore output since only exit code is used for conditional | ||
# only pull docker image if it's not available locally | ||
if ! docker inspect --type=image "${DOCKER_IMAGE}" >/dev/null 2>/dev/null; then | ||
retry docker pull "${DOCKER_IMAGE}" | ||
fi | ||
- name: Configure aws credentials (pytorch account) | ||
if: ${{ inputs.trigger-event == 'schedule' || (inputs.trigger-event == 'push' && startsWith(github.event.ref, 'refs/heads/nightly')) }} | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
role-to-assume: arn:aws:iam::749337293305:role/gha_workflow_nightly_build_wheels | ||
aws-region: us-east-1 | ||
|
||
- name: Configure aws credentials (pytorch account) | ||
if: ${{ env.CHANNEL == 'test' && startsWith(github.event.ref, 'refs/tags/v') }} | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
role-to-assume: arn:aws:iam::749337293305:role/gha_workflow_test_build_wheels | ||
aws-region: us-east-1 | ||
|
||
- name: Nightly or release RC | ||
if: ${{ inputs.trigger-event == 'schedule' || (inputs.trigger-event == 'push' && startsWith(github.event.ref, 'refs/heads/nightly')) || (env.CHANNEL == 'test' && startsWith(github.event.ref, 'refs/tags/')) }} | ||
shell: bash | ||
run: | | ||
set -ex | ||
echo "NIGHTLY_OR_TEST=1" >> "${GITHUB_ENV}" | ||
- name: Upload package to pytorch.org | ||
shell: bash | ||
working-directory: ${{ inputs.repository }} | ||
run: | | ||
set -ex | ||
# shellcheck disable=SC1090 | ||
source "${BUILD_ENV_FILE}" | ||
pip install awscli==1.32.18 | ||
AWS_CMD="aws s3 cp --dryrun" | ||
if [[ "${NIGHTLY_OR_TEST:-0}" == "1" ]]; then | ||
AWS_CMD="aws s3 cp" | ||
fi | ||
for pkg in dist/*; do | ||
${AWS_CMD} "$pkg" "${PYTORCH_S3_BUCKET_PATH}" --acl public-read | ||
done |