我是github行动的新手,我试图将多个图像推送到ECR并从ECS访问它。以下是我的工作流程:
- name: Build and push the images
run: |
for versionFilePath in $(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} ${{ github.event.before }} | grep "VERSION");
do
folder=${versionFilePath%"/VERSION"}
IMAGE_NAME=${folder##*/}
tmpName="image-$RANDOM"
docker build $folder --file $folder/Dockerfile --tag $tmpName
IMAGE_ID=${{ secrets.DOCKER_REGISTRY_URL }}/${{ secrets.REPOSITORY }}/$IMAGE_NAME
VERSION=$(cat $versionFilePath)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $tmpName $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
done;
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition service \
--query taskDefinition > task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: application
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ secrets.ECS_SERVICE }}
cluster: ${{ secrets.ECS_CLUSTER }}
wait-for-service-stability: true我能够成功地建立图像。但是,当生成多个映像时,${Stes.Build-Image.outputs.Image}只获取上次生成的图像的名称。是否可以将输出存储在数组中?
https://stackoverflow.com/questions/74440753
复制相似问题