fix: update submodules #17
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: Develop Images | |
| on: | |
| push: | |
| branches: | |
| - "dev/**" | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract branch tag | |
| id: tag | |
| run: | | |
| BRANCH=${{ github.ref_name }} | |
| if [[ ! "$BRANCH" =~ ^dev/ ]]; then | |
| echo "Branch não é do tipo dev/*. Saindo." | |
| exit 1 | |
| fi | |
| TAG="${BRANCH/dev\//}" | |
| echo "tag=v${TAG}" >> $GITHUB_OUTPUT | |
| echo "BRANCH=$BRANCH" >> $GITHUB_OUTPUT | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=raw,value=${{ steps.tag.outputs.tag }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| file: ./Dockerfile | |
| target: production | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64 | |
| - name: Checkout GitOps repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: lpirola/gitops-caicara-dev | |
| token: ${{ secrets.GITOPS_TOKEN }} | |
| path: gitops | |
| - name: Update GitOps values.yaml | |
| run: | | |
| IMAGE_TAG="${{ steps.tag.outputs.tag }}" | |
| # Update image tag in values.yaml | |
| sed -i "s/tag: .*/tag: ${IMAGE_TAG}/" gitops/clusters/production/applications/mapas/values.yaml | |
| # Show diff | |
| git -C gitops diff clusters/production/applications/mapas/values.yaml | |
| # Commit and push | |
| git -C gitops config user.name "github-actions[bot]" | |
| git -C gitops config user.email "github-actions[bot]@users.noreply.github.com" | |
| git -C gitops add clusters/production/applications/mapas/values.yaml | |
| git -C gitops commit -m "chore: update mapas image to ${IMAGE_TAG} (develop branch)" | |
| git -C gitops push | |
| helm-test: | |
| runs-on: ubuntu-latest | |
| needs: docker | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract branch tag | |
| id: tag | |
| run: | | |
| BRANCH=${{ github.ref_name }} | |
| TAG="${BRANCH/dev\//}" | |
| echo "tag=v${TAG}" >> $GITHUB_OUTPUT | |
| - name: Checkout GitOps repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: lpirola/gitops-caicara-dev | |
| path: gitops | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: "v3.16.0" | |
| - name: Create kind cluster | |
| uses: helm/kind-action@v1.10.0 | |
| with: | |
| cluster_name: mapas-test | |
| config: .github/kind-config.yaml | |
| - name: Load Docker image into kind | |
| run: | | |
| TAG="${{ steps.tag.outputs.tag }}" | |
| REPO="${{ github.repository }}" | |
| REPO_LOWER=$(echo "$REPO" | tr '[:upper:]' '[:lower:]') | |
| docker pull ghcr.io/${REPO_LOWER}:${TAG} | |
| kind load docker-image ghcr.io/${REPO_LOWER}:${TAG} --name mapas-test | |
| - name: Install helm chart | |
| run: | | |
| TAG="${{ steps.tag.outputs.tag }}" | |
| REPO="${{ github.repository }}" | |
| REPO_LOWER=$(echo "$REPO" | tr '[:upper:]' '[:lower:]') | |
| helm install mapas gitops/charts/mapas \ | |
| --namespace mapas-test \ | |
| --create-namespace \ | |
| --set image.repository=ghcr.io/${REPO_LOWER} \ | |
| --set image.tag=${TAG} \ | |
| --set postgresql.enabled=false \ | |
| --set redis.enabled=false \ | |
| --set redisSession.enabled=false \ | |
| --set env.MAPASCULTURAIS_SKIP_DB_INIT=true \ | |
| --wait \ | |
| --timeout 5m | |
| - name: Verify deployment | |
| run: | | |
| kubectl get pods -n mapas-test | |
| kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=mapas -n mapas-test --timeout=2m |