|
14 | 14 | DV_AWS_ECR_REGISTRY: |
15 | 15 | required: false |
16 | 16 | DV_BOT_USER: |
17 | | - required: true |
| 17 | + required: false |
| 18 | + DV_AWS_ECR_ROLE: |
| 19 | + required: false |
| 20 | + DV_AWS_REGION: |
| 21 | + required: false |
| 22 | + |
18 | 23 | inputs: |
19 | 24 | stage: |
20 | 25 | description: "stage that should be deployed (develop|qa|production)" |
|
24 | 29 | description: "customer for that the app should be deployed" |
25 | 30 | required: true |
26 | 31 | type: string |
| 32 | + add_revision_as_tag: |
| 33 | + description: "add revision label as tag" |
| 34 | + required: false |
| 35 | + type: boolean |
| 36 | + default: false |
| 37 | + outputs: |
| 38 | + revision_label: |
| 39 | + description: "revision that is stored as a label" |
| 40 | + value: ${{ jobs.deploy.outputs.revision_label }} |
| 41 | + |
27 | 42 |
|
28 | 43 | permissions: |
29 | 44 | id-token: write |
|
40 | 55 | jobs: |
41 | 56 | deploy: |
42 | 57 | runs-on: ubuntu-20.04 |
| 58 | + outputs: |
| 59 | + revision_label: ${{ steps.get-revision-label.outputs.revision_label }} |
43 | 60 | steps: |
44 | 61 | # checkout repo to get package.json |
45 | 62 | - uses: actions/checkout@v3 |
|
62 | 79 | branch_name: ${{ github.ref_name }} |
63 | 80 | time_zone: ${{ env.TIME_ZONE }} |
64 | 81 | - name: trigger deployment |
| 82 | + id: trigger-deployment |
65 | 83 | uses: datavisyn/github-action-trigger-workflow@v1 |
66 | 84 | with: |
67 | 85 | owner: "datavisyn" |
|
70 | 88 | workflow_file_name: "deploy-app.yml" |
71 | 89 | ref: ${{ env.WORKFLOW_BRANCH }} |
72 | 90 | github_user: ${{ secrets.DV_BOT_USER }} |
73 | | - client_payload: '{ "app": "${{ steps.get-parameters.outputs.app }}", "customer": "${{ inputs.customer }}", "stage": "${{ inputs.stage }}", "sub_app": "${{ steps.get-parameters.outputs.sub_app }}", "branch": "${{ steps.get-parameters.outputs.image_tag2 }}" }' |
| 91 | + client_payload: '{ "app": "${{ steps.get-parameters.outputs.app }}", "customer": "${{ inputs.customer }}", "stage": "${{ inputs.stage }}", "sub_app": "${{ steps.get-parameters.outputs.sub_app }}", "branch": "${{ steps.get-parameters.outputs.image_tag2 }}", "add_revision_as_tag": "${{ inputs.add_revision_as_tag }}" }' |
| 92 | + - name: Configure AWS Credentials |
| 93 | + if: ${{ inputs.add_revision_as_tag == true }} |
| 94 | + uses: aws-actions/[email protected] |
| 95 | + with: |
| 96 | + role-to-assume: ${{ secrets.DV_AWS_ECR_ROLE }} |
| 97 | + aws_role: ${{ secrets.DV_AWS_ECR_ROLE }} |
| 98 | + aws-region: ${{ secrets.DV_AWS_REGION }} |
| 99 | + - name: Login to Amazon ECR |
| 100 | + if: ${{ inputs.add_revision_as_tag == true }} |
| 101 | + id: login-ecr |
| 102 | + uses: aws-actions/[email protected] |
| 103 | + - name: get revision label |
| 104 | + id: get-revision-label |
| 105 | + if: ${{ inputs.add_revision_as_tag == true }} |
| 106 | + run: | |
| 107 | + echo "fetch labels of image" |
| 108 | + ECR_REPO=$(echo ${{ steps.get-parameters.outputs.ecr_repos }} | cut -d ',' -f 1) |
| 109 | + echo "ECR_REPO: $ECR_REPO" |
| 110 | + MANIFEST=$(aws ecr batch-get-image --repository-name "$ECR_REPO" --image-id imageTag="${{ steps.get-parameters.outputs.image_tag2 }}" --accepted-media-types "application/vnd.docker.distribution.manifest.v1+json" --output json |jq -r '.images[].imageManifest' |jq -r '.history[0].v1Compatibility' |jq -r '.config.Labels | to_entries | .[] | select(.key=="org.opencontainers.image.revision") | .value') |
| 111 | + echo "$MANIFEST" |
| 112 | + echo "revision_label=$MANIFEST" >> "$GITHUB_OUTPUT" |
0 commit comments