Merge pull request #69 from junkurihara/fix/no-cache-configs #164
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: Nightly and release build | ||
| on: | ||
| push: | ||
| branches: | ||
| - "feat/*" | ||
| - "develop" | ||
| pull_request: | ||
| types: [closed] | ||
| branches: | ||
| - main | ||
| env: | ||
| DH_REGISTRY_NAME: jqtype/modoh-server | ||
| GHCR: ghcr.io | ||
| GHCR_IMAGE_NAME: ${{ github.repository }} | ||
| jobs: | ||
| docker_build_and_push: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.event_name == 'push' }} || ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }} | ||
|
Check warning on line 21 in .github/workflows/release_docker.yml
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - target: "default" | ||
| dockerfile: ./docker/Dockerfile | ||
| platforms: linux/amd64 | ||
| # Aliases must be used only for release builds | ||
| aliases: | | ||
| jqtype/modoh-server:latest | ||
| ghcr.io/junkurihara/modoh-server:latest | ||
| - target: "slim" | ||
| dockerfile: ./docker/Dockerfile-slim | ||
| platforms: linux/amd64 | ||
| tags-suffix: "-slim" | ||
| # Aliases must be used only for release builds | ||
| aliases: | | ||
| jqtype/modoh-server:slim | ||
| ghcr.io/junkurihara/modoh-server:slim | ||
| steps: | ||
| - name: checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Docker meta | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.DH_REGISTRY_NAME }} | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.GHCR }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Release Build and push x86_64 | ||
| if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }} | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: | | ||
| ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:latest${{ matrix.tags-suffix }} | ||
| ${{ env.DH_REGISTRY_NAME }}:latest${{ matrix.tags-suffix }} | ||
| ${{ matrix.aliases }} | ||
| file: ${{ matrix.dockerfile }} | ||
| cache-from: type=gha,scope=modoh-server-latest | ||
| cache-to: type=gha,mode=max,scope=modoh-server-latest | ||
| platforms: ${{ matrix.platforms }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| - name: Nightly build and push x86_64 | ||
| if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }} | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: | | ||
| ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:nightly${{ matrix.tags-suffix }} | ||
| ${{ env.DH_REGISTRY_NAME }}:nightly${{ matrix.tags-suffix }} | ||
| file: ${{ matrix.dockerfile }} | ||
| cache-from: type=gha,scope=modoh-server-nightly | ||
| cache-to: type=gha,mode=max,scope=modoh-server-nightly | ||
| platforms: ${{ matrix.platforms }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| - name: Unstable build and push x86_64 for 'feat/*' branches (for development purposes) | ||
| if: ${{ startsWith(github.ref_name, 'feat/') && (github.event_name == 'push') }} | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: | | ||
| ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:unstable${{ matrix.tags-suffix }} | ||
| ${{ env.DH_REGISTRY_NAME }}:unstable${{ matrix.tags-suffix }} | ||
| file: ${{ matrix.dockerfile }} | ||
| cache-from: type=gha,scope=modoh-server-unstable | ||
| cache-to: type=gha,mode=max,scope=modoh-server-unstable | ||
| platforms: ${{ matrix.platforms }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| dispatch_release: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }} | ||
| needs: docker_build_and_push | ||
| steps: | ||
| - name: check pull_request title | ||
| uses: kaisugi/action-regex-match@v1.0.1 | ||
| id: regex-match | ||
| with: | ||
| text: ${{ github.event.pull_request.title }} | ||
| regex: "^(\\d+\\.\\d+\\.\\d+)$" | ||
| - name: checkout | ||
| if: ${{ steps.regex-match.outputs.match != '' }} | ||
| uses: actions/checkout@v4 | ||
| - name: build release binary | ||
| if: ${{ steps.regex-match.outputs.match != '' }} | ||
| id: "build" | ||
| run: | | ||
| cargo build --release --package modoh-server | ||
| cp ./target/release/modoh-server /tmp/modoh-server | ||
| cd /tmp | ||
| tar zcvf modoh-server-x86_64-unknown-linux-gnu.tar.gz modoh-server | ||
| - name: release | ||
| if: ${{ steps.regex-match.outputs.match != ''}} | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| files: /tmp/modoh-server-x86_64-unknown-linux-gnu.tar.gz | ||
| name: ${{ github.event.pull_request.title }} | ||
| tag_name: ${{ github.event.pull_request.title }} | ||
| body: ${{ github.event.pull_request.body }} | ||
| draft: true | ||
| prerelease: false | ||
| generate_release_notes: true | ||