update logic #39
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: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - v* | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| env: | |
| RUST_TOOLCHAIN: "1.94.1" | |
| jobs: | |
| formatting: | |
| name: Formatting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: ${{ env.RUST_TOOLCHAIN }} | |
| components: rustfmt | |
| - run: cargo fmt --check | |
| working-directory: ./rust | |
| clippy: | |
| name: Clippy Lints | |
| env: | |
| RUSTFLAGS: "-Dwarnings" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: ${{ env.RUST_TOOLCHAIN }} | |
| components: clippy | |
| - run: cargo clippy --all-targets | |
| working-directory: ./rust | |
| tests: | |
| name: Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: ${{ env.RUST_TOOLCHAIN }} | |
| - run: cargo test | |
| working-directory: ./rust | |
| build-docker: | |
| name: Build Docker image | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') | |
| env: | |
| DOCKER_TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || github.ref_name }} | |
| steps: | |
| - | |
| name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - | |
| name: Login to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - | |
| name: Build and push | |
| uses: docker/build-push-action@v3 | |
| with: | |
| push: true | |
| tags: | | |
| bkerby/map-rando:${{ env.DOCKER_TAG }} | |
| bkerby/map-rando:${{ github.sha }} | |
| cache-from: type=registry,ref=bkerby/map-rando:buildcache | |
| cache-to: type=registry,ref=bkerby/map-rando:buildcache,mode=max | |
| build-args: | | |
| GIT_COMMIT_HASH=${{ github.sha }} | |
| deploy-dev: | |
| name: Deploy to dev site | |
| runs-on: ubuntu-latest | |
| needs: build-docker | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - | |
| name: Install kubectl | |
| uses: azure/setup-kubectl@v3 | |
| - | |
| name: Deploy to Kubernetes | |
| run: | | |
| mkdir -p $HOME/.kube | |
| echo "${{ secrets.KUBECONFIG }}" > $HOME/.kube/config | |
| kubectl set image deployment/maprando-web-dev \ | |
| maprando-web-dev=bkerby/map-rando:${{ github.sha }} \ | |
| -n default | |
| kubectl rollout status deployment/maprando-web-dev -n default |