Skip to content

Commit

Permalink
new flow for test and release works
Browse files Browse the repository at this point in the history
  • Loading branch information
debdutdeb committed Jul 19, 2023
1 parent 9e82854 commit 9fdf4d2
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/force-release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Force update helm chart

# FIXME make this use release.yml

on:
workflow_dispatch:

Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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 }}
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9fdf4d2

Please sign in to comment.