feat: initial public release #35
Workflow file for this run
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: Update Documentation | |
| on: | |
| pull_request: | |
| paths: | |
| - apps/*/Chart.yaml | |
| - apps/*/README.md.gotmpl | |
| - apps/*/values.yaml | |
| - library/*/Chart.yaml | |
| - library/*/README.md.gotmpl | |
| - library/*/values.yaml | |
| concurrency: | |
| cancel-in-progress: true | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| defaults: | |
| run: | |
| shell: bash | |
| permissions: | |
| contents: write | |
| jobs: | |
| update: | |
| name: Update Documentation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install helm-docs package | |
| env: | |
| HELM_DOCS_URL: https://github.com/norwoodj/helm-docs/releases/download | |
| HELM_DOCS_VERSION: 1.14.2 | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const os = require('os'); | |
| const tmpDir = os.tmpdir(); | |
| const packagePath = [tmpDir, | |
| 'helm-docs_' + process.env.HELM_DOCS_VERSION + '_Linux_x86_64.deb' | |
| ].join('/'); | |
| const packageUrl = [process.env.HELM_DOCS_URL, 'v' + process.env.HELM_DOCS_VERSION, | |
| 'helm-docs_' + process.env.HELM_DOCS_VERSION + '_Linux_x86_64.deb' | |
| ].join('/'); | |
| const runSudo = async (args) => (await exec.exec('sudo', args)); | |
| try { | |
| await runSudo(['wget', '-qP', tmpDir, packageUrl]); | |
| await runSudo(['apt-get', '-y', 'install', packagePath]); | |
| } catch (error) { | |
| core.setFailed(error.message); | |
| } | |
| - name: Update documentation | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const fs = require('fs/promises'); | |
| const runGit = async (args) => (await exec.getExecOutput('git', args)).stdout.trim(); | |
| try { | |
| await Promise.all([ | |
| runGit(['config', 'user.name', 'github-actions[bot]']), | |
| runGit(['config', 'user.email', '41898282+github-actions[bot]@users.noreply.github.com']) | |
| ]); | |
| await runGit(['fetch', 'origin', process.env.GITHUB_HEAD_REF]); | |
| await runGit(['switch', process.env.GITHUB_HEAD_REF]); | |
| await exec.exec('helm-docs'); | |
| const files = (await runGit(['diff', '--name-only'])).split('\n').filter(Boolean); | |
| if (files.length === 0) { | |
| core.info('No file changes detected'); | |
| return; | |
| } | |
| const additions = await Promise.all((await runGit(['diff', '--name-only', '--diff-filter=ACMR'])) | |
| .split('\n') | |
| .filter(Boolean) | |
| .map(async file => { | |
| const contents = await fs.readFile(file, 'utf-8'); | |
| return { | |
| path: file, | |
| contents: Buffer.from(contents).toString('base64') | |
| }; | |
| }) | |
| ); | |
| const deletions = (await runGit(['diff', '--name-only', '--diff-filter=D'])) | |
| .split('\n') | |
| .filter(Boolean) | |
| .map(file => ({ path: file })); | |
| const input = { | |
| branch: { | |
| repositoryNameWithOwner: context.payload.repository.full_name, | |
| branchName: context.payload.pull_request.head.ref | |
| }, | |
| expectedHeadOid: context.payload.pull_request.head.sha, | |
| fileChanges: { | |
| additions: additions, | |
| deletions: deletions | |
| }, | |
| message: { headline: 'docs(github-action): update documentation' } | |
| }; | |
| const mutation = ` | |
| mutation CreateCommitOnBranch($input: CreateCommitOnBranchInput!) { | |
| createCommitOnBranch(input: $input) { commit { oid } } | |
| } | |
| `; | |
| const { createCommitOnBranch } = await github.graphql(mutation, { input }); | |
| core.info('Signed commit created with OID: ' + createCommitOnBranch.commit.oid); | |
| } catch (error) { | |
| core.setFailed(error.message); | |
| } |