|
54 | 54 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
55 | 55 | aws-region: eu-west-3 |
56 | 56 |
|
| 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 | +
|
57 | 78 | - name: Run training |
58 | 79 | env: |
59 | 80 | ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} |
|
62 | 83 | run: | |
63 | 84 | BRANCH_NAME=$(echo '${{ github.ref }}' | sed 's/[^[:alnum:]\.\_\-]/-/g') |
64 | 85 | 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}" \ |
66 | 87 | --role-arn arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-role/AmazonSageMaker-ExecutionRole-20230601T201737 \ |
67 | 88 | --resource-config InstanceCount=1,InstanceType=ml.g4dn.xlarge,VolumeSizeInGB=10 \ |
68 | 89 | --stopping-condition MaxRuntimeInSeconds=36000 \ |
|
0 commit comments