|
1 | | -name: Build middleware docker image |
| 1 | +name: Publish Docker image |
2 | 2 |
|
3 | 3 | on: |
| 4 | + release: |
| 5 | + types: [published] |
4 | 6 | workflow_dispatch: |
5 | | - branches: ["master", "main"] |
6 | | - |
7 | | -permissions: |
8 | | - contents: read |
9 | | - |
10 | | -env: |
11 | | - AWS_REGION: "ap-south-1" |
| 7 | + branches: [ "master", "main" ] |
12 | 8 |
|
13 | 9 | jobs: |
14 | | - build-and-push: |
| 10 | + push_to_registry: |
| 11 | + name: Push Docker image to Docker Hub |
15 | 12 | runs-on: ubuntu-latest |
16 | | - |
17 | 13 | steps: |
18 | | - - name: Configure AWS credentials |
19 | | - uses: aws-actions/configure-aws-credentials@v4 |
20 | | - with: |
21 | | - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
22 | | - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
23 | | - aws-region: "us-east-1" |
| 14 | + - name: Check out the repo |
| 15 | + uses: actions/checkout@v4 |
24 | 16 |
|
25 | | - - name: Checkout repository |
26 | | - uses: actions/checkout@v2 |
| 17 | + - name: Log in to Docker Hub |
| 18 | + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a |
27 | 19 | with: |
28 | | - ref: ${{ github.ref }} |
| 20 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 21 | + password: ${{ secrets.DOCKER_PASSWORD }} |
29 | 22 |
|
30 | | - - name: list file contents |
31 | | - run: ls -Alrt |
32 | | - |
33 | | - - name: Login to Amazon ECR Public |
34 | | - id: login-ecr-public |
35 | | - uses: aws-actions/amazon-ecr-login@v2 |
36 | | - with: |
37 | | - registry-type: public |
38 | | - |
39 | | - - name: Set up Docker |
40 | | - uses: crazy-max/ghaction-setup-docker@v3 |
| 23 | + - name: Extract metadata (tags, labels) for Docker |
| 24 | + id: meta |
| 25 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
41 | 26 | with: |
42 | | - daemon-config: | |
43 | | - { |
44 | | - "debug": true, |
45 | | - "features": { |
46 | | - "containerd-snapshotter": true |
47 | | - } |
48 | | - } |
49 | | - - name: Build Docker image |
50 | | - run: docker build --tag middleware:latest --platform linux/amd64,linux/arm64 . |
| 27 | + images: middlewareeng/middleware |
51 | 28 |
|
52 | | - - name: Tag Docker image |
53 | | - run: docker tag middleware:latest public.ecr.aws/y4x5l0o7/middleware:latest |
54 | | - |
55 | | - - name: Push Docker image to Amazon ECR |
56 | | - run: | |
57 | | - docker push public.ecr.aws/y4x5l0o7/middleware:latest |
| 29 | + - name: Build and push Docker image |
| 30 | + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 |
| 31 | + with: |
| 32 | + context: . |
| 33 | + file: ./Dockerfile |
| 34 | + platforms: linux/amd64,linux/arm64 |
| 35 | + push: true |
| 36 | + tags: ${{ steps.meta.outputs.tags }} |
| 37 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments