Skip to content

Commit 9a7b954

Browse files
committed
fix: ohyeah
1 parent a56af27 commit 9a7b954

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

.github/workflows/build-train.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ jobs:
5454
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5555
aws-region: eu-west-3
5656

57+
- name: Login to Amazon ECR
58+
id: login-ecr-private
59+
uses: aws-actions/amazon-ecr-login@v2
60+
61+
- name: Build, tag, and push image to Amazon ECR
62+
env:
63+
ECR_REGISTRY: ${{ steps.login-ecr-private.outputs.registry }}
64+
ECR_REPOSITORY: minecraft-copilot-ml
65+
IMAGE_TAG: ${{ github.sha }}
66+
run: |
67+
BRANCH_NAME=$(echo '${{ github.ref }}' | sed 's/[^[:alnum:]\.\_\-]/-/g')
68+
export DOCKER_BUILDKIT=1
69+
docker pull $ECR_REGISTRY/$ECR_REPOSITORY:latest || echo 'The image does not exist yet.'
70+
docker build . --cache-from $ECR_REGISTRY/$ECR_REPOSITORY:latest --build-arg BUILDKIT_INLINE_CACHE=1 -t minecraft-copilot-ml
71+
# docker tag minecraft-copilot-ml $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
72+
docker tag minecraft-copilot-ml $ECR_REGISTRY/$ECR_REPOSITORY:$BRANCH_NAME
73+
if [ ${{ github.ref }} = 'refs/heads/master' ]; then
74+
docker tag minecraft-copilot-ml $ECR_REGISTRY/$ECR_REPOSITORY:latest
75+
fi
76+
docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags
77+
5778
- name: Run training
5879
env:
5980
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
@@ -62,7 +83,7 @@ jobs:
6283
run: |
6384
BRANCH_NAME=$(echo '${{ github.ref }}' | sed 's/[^[:alnum:]\.\_\-]/-/g')
6485
aws sagemaker create-training-job --training-job-name minecraft-copilot-ml-${{ github.sha }} \
65-
--algorithm-specification "TrainingImage=$ECR_REGISTRY/$ECR_REGISTRY_ALIAS/$ECR_REPOSITORY:${{ github.sha }},TrainingInputMode=File" \
86+
--algorithm-specification "TrainingImage=$ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }},TrainingInputMode=File,TrainingImageConfig={TrainingRepositoryAccessMode=Vpc}" \
6687
--role-arn arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-role/AmazonSageMaker-ExecutionRole-20230601T201737 \
6788
--resource-config InstanceCount=1,InstanceType=ml.g4dn.xlarge,VolumeSizeInGB=10 \
6889
--stopping-condition MaxRuntimeInSeconds=36000 \

0 commit comments

Comments
 (0)