Build and push mall images #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and push mall images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build_and_push_images: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| file_tag: | |
| - file: ./docker/backend/mall-admin/Dockerfile | |
| repo: mall-admin | |
| context: ./docker/backend/mall-admin | |
| - file: ./docker/backend/mall-auth/Dockerfile | |
| repo: mall-auth | |
| context: ./docker/backend/mall-auth | |
| - file: ./docker/backend/mall-gateway/Dockerfile | |
| repo: mall-gateway | |
| context: ./docker/backend/mall-gateway | |
| - file: ./docker/backend/mall-portal/Dockerfile | |
| repo: mall-portal | |
| context: ./docker/backend/mall-portal | |
| - file: ./docker/backend/mall-search/Dockerfile | |
| repo: mall-search | |
| context: ./docker/backend/mall-search | |
| steps: | |
| - name: Set up Java | |
| uses: actions/setup-java@v1 | |
| with: | |
| java-version: 11 | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Cache dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.m2/repository | |
| key: Linux-java-0708c922d4bf4dab90192af21a5e94f25f35379430c7d269d18c20fe0d77cc10 | |
| restore-keys: | | |
| Linux-java- | |
| - name: Build with Maven | |
| run: mvn clean package -Dmaven.test.skip=true | |
| - name: Copy jar to folder | |
| run: cd ./docker && bash copy-jar.sh | |
| shell: bash | |
| - name: Log in to the Docker registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ vars.DOCKER_REGISTRY }} | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| image: tonistiigi/binfmt:master | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| config-inline: | | |
| [worker.oci] | |
| max-parallelism = 2 | |
| - name: Matrix Build and push demo images | |
| uses: docker/build-push-action@v3.3.1 | |
| with: | |
| context: ${{ matrix.file_tag.context }} | |
| file: ${{ matrix.file_tag.file }} | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_NAMESPACE }}/${{ matrix.file_tag.repo }}:${{ github.sha }} | |
| ${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_NAMESPACE }}/${{ matrix.file_tag.repo }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha |