Merge pull request #270 from SEMOSAN/feat/#267-admin-auth #149
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: Deploy | |
| on: | |
| push: | |
| branches: [main, develop] | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Build with Gradle | |
| run: ./gradlew build -x test --no-daemon --parallel --build-cache | |
| - name: Set image name (lowercase) | |
| run: echo "IMAGE=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/arm64 | |
| push: true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| tags: | | |
| ${{ env.IMAGE }}:${{ github.sha }} | |
| ${{ env.IMAGE }}:latest | |
| - name: Update image tag in kustomization | |
| if: github.ref_name == 'develop' | |
| run: | | |
| sed -i "s|newTag: .*|newTag: ${{ github.sha }}|" k8s/kustomization.yaml | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add k8s/kustomization.yaml | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: update image to ${{ github.sha }} [skip ci]" | |
| git push origin HEAD:${{ github.ref_name }} | |
| fi | |