|
| 1 | +name: CI-trigger-by-tag |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | +env: |
| 8 | + REGION: us-east-1 |
| 9 | + ECR_REGISTRY_ID: 553885929720 |
| 10 | + |
| 11 | +jobs: |
| 12 | + ci-lint: |
| 13 | + runs-on: [self-hosted,qa-infra-k8s] |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + - name: static check |
| 19 | + id: static-check |
| 20 | + # TODO: developers need to add static check scripts |
| 21 | + run: | |
| 22 | + echo "static check" |
| 23 | + ci-tests: |
| 24 | + runs-on: [self-hosted,qa-infra-k8s] |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + with: |
| 28 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + - name: unit tests |
| 30 | + id: unit-tests |
| 31 | + # TODO: developers need to add unit test scripts |
| 32 | + run: | |
| 33 | + echo "unit tests" |
| 34 | + ci-build: |
| 35 | + runs-on: [self-hosted,qa-infra-k8s] |
| 36 | + needs: [ci-lint, ci-tests] |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + - name: Configure AWS credentials |
| 42 | + uses: aws-actions/configure-aws-credentials@v2 # More information on this action can be found below in the 'AWS Credentials' section |
| 43 | + with: |
| 44 | + role-to-assume: arn:aws:iam::553885929720:role/tf_nodereal_prod_ecr_cicd_deployment_assume_role |
| 45 | + aws-region: us-east-1 |
| 46 | + role-duration-seconds: 1800 |
| 47 | + - name: Build, tag, and push image to Amazon ECR |
| 48 | + env: |
| 49 | + OP_NODE_IMAGE_REPO: op-node |
| 50 | + OP_BATCHER_IMAGE_REPO: op-batcher |
| 51 | + OP_PROPOSER_IMAGE_REPO: op-proposer |
| 52 | + run: | |
| 53 | +
|
| 54 | + OP_NODE_IMAGE_NAME="${ECR_REGISTRY_ID}.dkr.ecr.${REGION}.amazonaws.com/$OP_NODE_IMAGE_REPO:${GITHUB_REF#refs/*/}" |
| 55 | + OP_BATCHER_IMAGE_NAME="${ECR_REGISTRY_ID}.dkr.ecr.${REGION}.amazonaws.com/$OP_BATCHER_IMAGE_REPO:${GITHUB_REF#refs/*/}" |
| 56 | + OP_PROPOSER_IMAGE_NAME="${ECR_REGISTRY_ID}.dkr.ecr.${REGION}.amazonaws.com/$OP_PROPOSER_IMAGE_REPO:${GITHUB_REF#refs/*/}" |
| 57 | +
|
| 58 | + aws ecr get-login-password --region ${REGION} | docker login --username AWS --password-stdin ${ECR_REGISTRY_ID}.dkr.ecr.${REGION}.amazonaws.com |
| 59 | +
|
| 60 | + aws ecr --region $REGION describe-repositories --registry-id $ECR_REGISTRY_ID --repository-names $OP_NODE_IMAGE_REPO || aws ecr --region $REGION create-repository --registry-id $ECR_REGISTRY_ID --repository-name $OP_NODE_IMAGE_REPO |
| 61 | + aws ecr --region $REGION set-repository-policy --registry-id $ECR_REGISTRY_ID --repository-name $OP_NODE_IMAGE_REPO --policy-text file:///home/runner/repo-access-permissions.json |
| 62 | +
|
| 63 | + aws ecr --region $REGION describe-repositories --registry-id $ECR_REGISTRY_ID --repository-names $OP_BATCHER_IMAGE_REPO || aws ecr --region $REGION create-repository --registry-id $ECR_REGISTRY_ID --repository-name $OP_BATCHER_IMAGE_REPO |
| 64 | + aws ecr --region $REGION set-repository-policy --registry-id $ECR_REGISTRY_ID --repository-name $OP_BATCHER_IMAGE_REPO --policy-text file:///home/runner/repo-access-permissions.json |
| 65 | +
|
| 66 | + aws ecr --region $REGION describe-repositories --registry-id $ECR_REGISTRY_ID --repository-names $OP_PROPOSER_IMAGE_REPO || aws ecr --region $REGION create-repository --registry-id $ECR_REGISTRY_ID --repository-name $OP_PROPOSER_IMAGE_REPO |
| 67 | + aws ecr --region $REGION set-repository-policy --registry-id $ECR_REGISTRY_ID --repository-name $OP_PROPOSER_IMAGE_REPO --policy-text file:///home/runner/repo-access-permissions.json |
| 68 | +
|
| 69 | + docker build --build-arg GIT_TOKEN=${{ secrets.GO_MODULES_TOKEN }} -t $OP_NODE_IMAGE_NAME -f op-node/Dockerfile . |
| 70 | + docker push $OP_NODE_IMAGE_NAME |
| 71 | +
|
| 72 | + docker build --build-arg GIT_TOKEN=${{ secrets.GO_MODULES_TOKEN }} -t $OP_BATCHER_IMAGE_NAME -f op-batcher/Dockerfile . |
| 73 | + docker push $OP_BATCHER_IMAGE_NAME |
| 74 | +
|
| 75 | + docker build --build-arg GIT_TOKEN=${{ secrets.GO_MODULES_TOKEN }} -t $OP_PROPOSER_IMAGE_NAME -f op-proposer/Dockerfile . |
| 76 | + docker push $OP_PROPOSER_IMAGE_NAME |
| 77 | + |
0 commit comments