[INFRA-190] Adding PR checks #2
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: PR Checks | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| run_checks: | |
| permissions: | |
| contents: read | |
| packages: read | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if chart version is updated | |
| id: check-version | |
| uses: oras-project/setup-oras@v1 | |
| - run: | | |
| CHART_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}') | |
| echo "CHART_VERSION=${CHART_VERSION}" >> $GITHUB_ENV | |
| oras repo tags ghcr.io/kobotoolbox/kobo | grep -qvz "${CHART_VERSION}" | |
| echo "VALID_VERSION=1" >> $GITHUB_ENV | |
| - name: Set up Helm | |
| uses: alexellis/arkade-get@master | |
| with: | |
| helm: latest | |
| - name: Verify helm chart is valid | |
| run: | | |
| helm lint --strict --set kpi.env.secret.DATABASE_URL=test --set kobotoolbox.kobocatDatabase=test --set kpi.version=test | |
| - name: Fail if chart version is not updated | |
| if: failure() | |
| run: | | |
| if [ "${{ env.VALID_VERSION }}" != "1" ]; then | |
| echo "Helm chart linting failed. Please fix the issues before merging." | |
| else | |
| echo "The chart version ${CHART_VERSION} is not updated. Please update the version in Chart.yaml before merging." | |
| fi | |
| exit 1 |