feat: Deploy keycloak branch to K8s dev env #4
Workflow file for this run
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: Keycloak Admin API CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - keycloak | |
| pull_request: | |
| branches: | |
| - keycloak | |
| env: | |
| project-directory: ./ | |
| jobs: | |
| test: | |
| name: Test API Project | |
| runs-on: ubuntu-latest | |
| if: | | |
| !contains(github.event.head_commit.message, 'skip-ci') | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Use Node.js 20.x | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20.x' | |
| - name: npm clean install | |
| run: npm ci | |
| working-directory: ${{ env.project-directory }} | |
| - name: run ESLint | |
| run: npm run lint | |
| working-directory: ${{ env.project-directory }} | |
| - name: build api project | |
| run: npm run build | |
| working-directory: ${{ env.project-directory }} | |
| - name: run api tests | |
| run: npm run test:ci | |
| working-directory: ${{ env.project-directory }} | |
| release: | |
| name: Build and Deploy Keycloak | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: | | |
| !contains(github.event.head_commit.message, 'skip-ci') && | |
| github.event_name == 'push' && | |
| github.repository == 'Greenstand/treetracker-admin-api' | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| ref: keycloak | |
| - name: Set short SHA | |
| id: sha | |
| run: echo "short=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v1 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| id: docker_build_release | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: ./ | |
| file: ./Dockerfile | |
| push: true | |
| tags: greenstand/treetracker-admin-api:keycloak-${{ steps.sha.outputs.short }} | |
| - name: Install kustomize | |
| run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash | |
| - name: Update kustomize image tag | |
| run: (cd deployment/overlays/keycloak-development && ../../../kustomize edit set image greenstand/treetracker-admin-api:keycloak-${{ steps.sha.outputs.short }} ) | |
| - name: Commit kustomization file with new image tag | |
| if: | | |
| !startsWith(github.event.head_commit.message, 'chore') | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git commit -am "chore: bump keycloak docker image tag keycloak-${{ steps.sha.outputs.short }} [skip ci]" | |
| - name: Push changes | |
| uses: ad-m/github-push-action@master | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: keycloak |