diff --git a/.github/workflows/force-release.yml b/.github/workflows/force-release.yml index 42b2465..086c66e 100644 --- a/.github/workflows/force-release.yml +++ b/.github/workflows/force-release.yml @@ -1,5 +1,7 @@ name: Force update helm chart +# FIXME make this use release.yml + on: workflow_dispatch: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e690ac2 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,30 @@ +name: Test and/or release helm chart + +on: + workflow_call: + secrets: + github-token: + required: true + inputs: + tag: + required: true + type: string + +env: + REPO: RocketChat/helm-charts + +jobs: + can-chart-run: + uses: ${{ env.REPO }}/.github/workflows/test.yml@master + with: + tag: ${{ inputs.tag }} + + update-release: + needs: + - can-chart-run + if: ! contains(inputs.tag, 'rc') + uses: ${{ env.REPO }}/.github/workflows/release.yml@master + with: + tag: ${{ inputs.tag }} + secrets: + github-token: ${{ secrets.github-token }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6af9251 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,90 @@ +name: Release helm chart + +on: + workflow_call: + secrets: + github-token: + required: true + inputs: + tag: + type: string + required: true + +env: + REPO: 'RocketChat/helm-charts' + + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Clone helm repo + uses: actions/checkout@v2 + with: + repository: ${{ env.REPO }} + path: ./helm-charts + token: ${{ secrets.github-token }} + + - name: Clone helm repo (gh-pages) + uses: actions/checkout@v2 + with: + repository: ${{ env.REPO }} + ref: gh-pages + path: ./gh-pages + token: ${{ secrets.github-token }} + + - name: Update chart and rocketchat versions + shell: bash + id: version + run: | + sed -i -r '/^appVersion:/ s/ .+/ ${{ inputs.tag }}/' ./helm-charts/rocketchat/Chart.yaml + sed -i -r '/^version:/ s/ .+/ ${{ inputs.tag }}/' ./helm-charts/rocketchat/Chart.yaml + + - name: Pull dependencies + shell: bash + run: helm dependency update ./helm-charts/rocketchat + + - name: Generate helm package + shell: bash + run: helm package ./helm-charts/rocketchat -d gh-pages/charts/ + + - name: Re-generate helm index + run: helm repo index ./gh-pages/ + + - name: Push to master + uses: EndBug/add-and-commit@v9 + with: + add: "rocketchat/Chart.yaml" + cwd: helm-charts + message: "Chore: bump Rocket.Chat and chart version to ${{ inputs.tag }}" + push: true + + - name: Push to gh-pages + uses: EndBug/add-and-commit@v9 + with: + add: "." + cwd: gh-pages + message: "Chore: bump Rocket.Chat and chart version to ${{ inputs.tag }}" + push: true + + - name: Create a release with artifact + uses: softprops/action-gh-release@v1 + with: + files: ${{ format('./gh-pages/charts/rocketchat-{0}.tgz', inputs.tag) }} + prerelease: false + repository: ${{ env.REPO }} + token: ${{ secrets.github-token }} + name: ${{ inputs.tag }} + tag_name: ${{ inputs.tag }} + body: ${{ format('https://github.com/RocketChat/Rocket.Chat/releases/{0}', inputs.tag) }} + draft: false + + - name: Notify core team + if: always() + uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master + with: + job_name: ${{ format('*Helm {0} release*', inputs.tag) }} + url: ${{ secrets.rocketchat-webhook }} + type: ${{ job.status }} + mention: 'debdut.chakraborty' + mention_if: failure diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fa54a58 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,46 @@ +name: Test helm chart + +on: + workflow_call: + inputs: + tag: + type: string + required: true + workflow_dispatch: + inputs: + tag: + required: true + +env: + REPO: 'RocketChat/helm-charts' + TESTS_REPO: 'debdutdeb/rocket.chat.tests' + + +jobs: + can-i-run: + runs-on: ubuntu-latest + steps: + - name: Clone helm chart repository + uses: actions/checkout@v3 + with: + repository: ${{ env.REPO }} + path: ./helm-charts + - name: Clone tests + uses: actions/checkout@v3 + with: + repository: ${{ env.TESTS_REPO }} + path: tests + submodules: true + - name: Setup k3d + uses: nolar/setup-k3d-k3s@v1 + - name: Run tests + shell: bash + env: + ROCKETCHAT_MAX_ATTEMPTS: 250 + ROCKETCHAT_TAG: ${{ inputs.tag }} + run: | + sudo apt-get install --no-install-recommends -y jo jq + export ROCKETCHAT_CHART_DIR="$(realpath ./helm-charts/rocketchat)" + cd tests && + bash run_k8s.bash +