name: CI Main on: push: branches: - main workflow_dispatch: jobs: load-config: name: Load example-gitea-env.conf to pipeline env uses: niko/gitea-ci-library/.gitea/workflows/config-provider.yml@main secrets: inherit with: config_path: .gitea/workflows/example-gitea-env.conf check-version: name: Check existing artifact needs: [load-config] uses: niko/gitea-ci-library/.gitea/workflows/check-version.yml@main secrets: inherit with: env_json: ${{ needs.load-config.outputs.env_json }} bats: name: Bats tests needs: [load-config, check-version] if: needs.check-version.outputs.artifact_exists != 'true' uses: niko/gitea-ci-library/.gitea/workflows/example-bats-tests.yml@main secrets: inherit with: env_json: ${{ needs.load-config.outputs.env_json }} cucumber: name: Cucumber tests needs: [load-config, check-version] if: needs.check-version.outputs.artifact_exists != 'true' uses: niko/gitea-ci-library/.gitea/workflows/example-cucumber-tests.yml@main secrets: inherit with: env_json: ${{ needs.load-config.outputs.env_json }} docker-build-push: name: Build & Push Docker needs: [load-config, check-version, bats, cucumber] if: needs.check-version.outputs.artifact_exists != 'true' uses: niko/gitea-ci-library/.gitea/workflows/docker-build-push.yml@main secrets: inherit with: env_json: ${{ needs.load-config.outputs.env_json }} version: ${{ needs.check-version.outputs.version }} helm-build-push: name: Build & Push Helm needs: [load-config, check-version, bats, cucumber] if: needs.check-version.outputs.artifact_exists != 'true' uses: niko/gitea-ci-library/.gitea/workflows/helm-build-push.yml@main secrets: inherit with: env_json: ${{ needs.load-config.outputs.env_json }} version: ${{ needs.check-version.outputs.version }} gitops-chart: name: GitOps — helm version needs: [helm-build-push] if: success() runs-on: ubuntu-latest outputs: chart_commit: ${{ steps.update.outputs.chart_commit }} steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: repository: niko/gitea-ci-library path: .ci - name: Update Chart.yaml version id: update run: | INPUTS=$(jq -nc \ --arg file "dev/Chart.yaml" \ --arg yq_tpl '(.dependencies[] | select(.name == "git-pages") | .version) = "{{VERSION}}"' \ --arg version "${{ needs.check-version.outputs.version }}" \ --arg source_repo "${{ github.repository }}" \ --arg source_commit "${{ github.sha }}" \ --arg git_tag_prefix "helm" \ '{file: $file, yq_tpl: $yq_tpl, version: $version, source_repo: $source_repo, source_commit: $source_commit, git_tag_prefix: $git_tag_prefix}') OUTPUT=$(bash .ci/scripts/dispatch-workflow.sh \ "niko/gitea-ci-gitops-tests" "gitops-service.yaml" "main" \ "$INPUTS" "${{ fromJson(needs.load-config.outputs.env_json).GITEA_API_URL }}" \ "${{ secrets.GITOPS_DISPATCH_TOKEN }}" "30") echo "$OUTPUT" CHART_REPO=$(echo "$OUTPUT" | grep '^GITOPS_COMMIT=' | cut -d= -f2) echo "chart_commit=$CHART_REPO" >> "$GITHUB_OUTPUT" gitops-values: name: GitOps — docker tag needs: [docker-build-push] if: success() runs-on: ubuntu-latest outputs: values_commit: ${{ steps.update.outputs.values_commit }} steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: repository: niko/gitea-ci-library path: .ci - name: Update values.yaml tag id: update run: | INPUTS=$(jq -nc \ --arg file "dev/values.yaml" \ --arg yq_tpl '.service.tag = "{{VERSION}}"' \ --arg version "${{ needs.check-version.outputs.version }}" \ --arg source_repo "${{ github.repository }}" \ --arg source_commit "${{ github.sha }}" \ --arg git_tag_prefix "docker" \ '{file: $file, yq_tpl: $yq_tpl, version: $version, source_repo: $source_repo, source_commit: $source_commit, git_tag_prefix: $git_tag_prefix}') OUTPUT=$(bash .ci/scripts/dispatch-workflow.sh \ "niko/gitea-ci-gitops-tests" "gitops-service.yaml" "main" \ "$INPUTS" "${{ fromJson(needs.load-config.outputs.env_json).GITEA_API_URL }}" \ "${{ secrets.GITOPS_DISPATCH_TOKEN }}" "30") echo "$OUTPUT" VALUES_REPO=$(echo "$OUTPUT" | grep '^GITOPS_COMMIT=' | cut -d= -f2) echo "values_commit=$VALUES_REPO" >> "$GITHUB_OUTPUT" report-summary: name: Report Summary needs: [load-config, docker-build-push, helm-build-push] if: always() uses: niko/gitea-ci-library/.gitea/workflows/report-summary.yml@main with: env_json: ${{ needs.load-config.outputs.env_json }} suites: bats cucumber gitops-summary: name: GitOps Summary needs: [load-config, check-version, gitops-chart, gitops-values] if: always() runs-on: ubuntu-latest steps: - name: Write GitOps summary run: | GITEA_URL="${{ fromJson(needs.load-config.outputs.env_json).GITEA_API_URL }}" CHART_COMMIT="${{ needs.gitops-chart.outputs.chart_commit }}" VALUES_COMMIT="${{ needs.gitops-values.outputs.values_commit }}" CHART_LINK="${GITEA_URL}/niko/gitea-ci-gitops-tests/commit/${CHART_COMMIT}" VALUES_LINK="${GITEA_URL}/niko/gitea-ci-gitops-tests/commit/${VALUES_COMMIT}" cat >> "$GITHUB_STEP_SUMMARY" << 'GITOPS' ## GitOps updates | Component | Version | Status | GitOps commit | |-----------|---------|--------|--------------| GITOPS { echo "| helm | ${{ needs.check-version.outputs.version }} | ${{ needs.gitops-chart.result }} | [link](${CHART_LINK}) |" echo "| docker | ${{ needs.check-version.outputs.version }} | ${{ needs.gitops-values.result }} | [link](${VALUES_LINK}) |" } >> "$GITHUB_STEP_SUMMARY" tag-maintenance: name: Move provider version tag needs: [docker-build-push, helm-build-push] if: success() uses: niko/gitea-ci-library/.gitea/workflows/tag-maintenance.yml@main secrets: inherit