add cache configuration for Docker build in CI workflow #5
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: CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| # Publish semver tags as releases. | |
| tags: [ 'v*.*.*' ] | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| REGISTRY: docker.io | |
| DOCKER_USERNAME: argentinaluiz | |
| IMAGE_NAME: argentinaluiz/docker-prod-test | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log into registry ${{ env.REGISTRY }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ env.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_TOKEN }} | |
| - name: Build for CI | |
| id: build-ci | |
| uses: docker/[email protected] | |
| with: | |
| context: ./src/ci/nestjs-project | |
| file: ./src/ci/nestjs-project/Dockerfile.prod | |
| push: false | |
| load: true # driver docker-container | |
| target: ci | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:ci | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| secrets: | | |
| github_token=${{ secrets.MY_GITHUB_TOKEN }} | |