|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - v** |
| 7 | +env: |
| 8 | + AWS_REGION: us-west-2 |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-rpc-auth-proxy: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v2 |
| 16 | + - name: Set up QEMU |
| 17 | + uses: docker/setup-qemu-action@v2 |
| 18 | + - name: Set up Docker Buildx |
| 19 | + uses: docker/setup-buildx-action@v2 |
| 20 | + - name: Login to Docker Hub |
| 21 | + uses: docker/login-action@v2 |
| 22 | + with: |
| 23 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 24 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 25 | + - name: Configure AWS credentials |
| 26 | + uses: aws-actions/configure-aws-credentials@v4 |
| 27 | + with: |
| 28 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 29 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 30 | + aws-region: ${{ env.AWS_REGION }} |
| 31 | + - name: Login to Amazon ECR |
| 32 | + id: login-ecr |
| 33 | + uses: aws-actions/amazon-ecr-login@v2 |
| 34 | + - name: check repo and create it if not exist |
| 35 | + env: |
| 36 | + REPOSITORY: rpc-auth-proxy |
| 37 | + run: | |
| 38 | + aws --region ${{ env.AWS_REGION }} ecr describe-repositories --repository-names ${{ env.REPOSITORY }} && : || aws --region ${{ env.AWS_REGION }} ecr create-repository --repository-name ${{ env.REPOSITORY }} |
| 39 | + - name: Build and push |
| 40 | + uses: docker/build-push-action@v3 |
| 41 | + env: |
| 42 | + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} |
| 43 | + REPOSITORY: rpc-auth-proxy |
| 44 | + IMAGE_TAG: ${{ github.ref_name }} |
| 45 | + with: |
| 46 | + context: . |
| 47 | + push: true |
| 48 | + tags: | |
| 49 | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} |
| 50 | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:latest |
| 51 | + ${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} |
| 52 | + ${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY }}:latest |
0 commit comments