| 
1 |  | -name: Build and Push Docker Image  | 
 | 1 | +name: Deploy Existing Image  | 
2 | 2 | 
 
  | 
3 | 3 | on:  | 
4 |  | -  push:  | 
5 |  | -    branches:  | 
6 |  | -      - main  | 
7 |  | -    tags:  | 
8 |  | -      - 'v*'  | 
9 |  | -  pull_request:  | 
10 |  | -    branches:  | 
11 |  | -      - main  | 
12 |  | - | 
13 |  | -env:  | 
14 |  | -  ECR_REGISTRY: ${{ vars.ECR_REGISTRY }}  | 
15 |  | -  ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}  | 
16 |  | -  AWS_REGION: ${{ vars.AWS_REGION }}  | 
 | 4 | +  workflow_dispatch:  | 
 | 5 | +    inputs:  | 
 | 6 | +      image_tag:  | 
 | 7 | +        description: 'Image tag to deploy (e.g. v1.2.3)'  | 
 | 8 | +        required: true  | 
 | 9 | +        type: string  | 
17 | 10 | 
 
  | 
18 | 11 | permissions:  | 
19 |  | -  id-token: write  | 
20 |  | -  contents: read  | 
21 |  | -  actions: read  | 
 | 12 | +  contents: write  | 
22 | 13 | 
 
  | 
23 | 14 | jobs:  | 
24 |  | -  build-and-test:  | 
 | 15 | +  prepare:  | 
25 | 16 |     runs-on: [mend-self-hosted, profile=sast-qa]  | 
26 |  | - | 
 | 17 | +    outputs:  | 
 | 18 | +      TAG: ${{ steps.set-tag.outputs.TAG }}  | 
27 | 19 |     steps:  | 
28 |  | -      - name: Checkout code  | 
29 |  | -        uses: actions/checkout@v4  | 
30 |  | - | 
31 |  | -      - name: Setup Go  | 
32 |  | -        uses: actions/setup-go@v5  | 
33 |  | -        with:  | 
34 |  | -          go-version: '1.24.4'  | 
35 |  | - | 
36 |  | -      - name: Install Task  | 
37 |  | -        uses: arduino/setup-task@v2  | 
38 |  | - | 
39 |  | -      - name: Run unit tests  | 
40 |  | -        run: task test  | 
41 |  | - | 
42 |  | -      - name: Run build (local Go binary)  | 
43 |  | -        run: task app:build  | 
44 |  | - | 
45 |  | -      - name: Configure AWS credentials  | 
46 |  | -        uses: aws-actions/configure-aws-credentials@v4  | 
47 |  | -        with:  | 
48 |  | -          role-to-assume: ${{ vars.AWS_IAM_ROLE_ARN }}  | 
49 |  | -          role-session-name: GitHubActionsSession  | 
50 |  | -          aws-region: ${{ env.AWS_REGION }}  | 
51 |  | - | 
52 |  | -      - name: Login to Amazon ECR  | 
53 |  | -        id: login-ecr  | 
54 |  | -        uses: aws-actions/amazon-ecr-login@v2  | 
55 |  | - | 
56 |  | -      - name: Extract metadata  | 
57 |  | -        id: meta  | 
58 |  | -        uses: docker/metadata-action@v5  | 
59 |  | -        with:  | 
60 |  | -          images: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}  | 
61 |  | -          tags: |  | 
62 |  | -            type=ref,event=pr  | 
63 |  | -            type=sha,prefix=sha-,format=short  | 
64 |  | -            type=raw,value=latest,enable={{is_default_branch}}  | 
65 |  | -
  | 
66 |  | -      - name: Build and push Docker image  | 
67 |  | -        uses: docker/build-push-action@v5  | 
 | 20 | +      - id: set-tag  | 
 | 21 | +        run: echo "TAG=${{ github.event.inputs.image_tag }}" >> "$GITHUB_OUTPUT"  | 
 | 22 | + | 
 | 23 | +  deploy-and-wait-for-sync:  | 
 | 24 | +    needs: [prepare]  | 
 | 25 | +    runs-on: [mend-self-hosted, profile=arch-small]  | 
 | 26 | +    env:  | 
 | 27 | +      IMAGE_TAG: ${{ needs.prepare.outputs.TAG }}  | 
 | 28 | +    steps:  | 
 | 29 | +      - name: Check out Mend helm-charts Repo  | 
 | 30 | +        uses: actions/checkout@v3  | 
68 | 31 |         with:  | 
69 |  | -          context: .  | 
70 |  | -          push: ${{ github.event_name != 'pull_request' }}  | 
71 |  | -          tags: ${{ steps.meta.outputs.tags }}  | 
72 |  | -          labels: ${{ steps.meta.outputs.labels }}  | 
 | 32 | +          repository: mend/helm-charts  | 
 | 33 | +          token: ${{ secrets.GH_TOKEN }}  | 
 | 34 | +          ref: main  | 
 | 35 | +          path: helm-charts-clone  | 
 | 36 | + | 
 | 37 | +      - name: Change image in helm chart values file  | 
 | 38 | +        run: |  | 
 | 39 | +          cd ./helm-charts-clone/values/reportportal-mcp-server/infra  | 
 | 40 | +          sed -i 's/tag: .*/tag: '"${IMAGE_TAG}"'/g' ./values-infra-dev.yaml  | 
 | 41 | +          git config --global user.name 'AutoRelease'  | 
 | 42 | +          git config --global user.email 'AutoRelease'  | 
 | 43 | +          git add .  | 
 | 44 | +          git commit -m "GH Actions AutoRelease ${IMAGE_TAG}" || echo "No changes to commit"  | 
 | 45 | +          git push  | 
0 commit comments