Skip to content

Push

Push #111

Workflow file for this run

name: Push
on:
push:
branches:
- master
tags:
- '*'
paths:
- 'storm/Chart.yaml'
# When this workflow is invoked by another repo
workflow_dispatch:
inputs:
owner:
description: "The owner of the repo who initialized this workflow"
required: true
type: string
repo:
description: "The repository name which wants to publish the chart"
required: true
type: string
ref:
description: "Branch name or tag which will be used for chart version"
required: true
type: string
env:
# Used for charts unit testing in packageChart.js
HELM_UNITTEST_VERSION: 0.4.1
jobs:
push:
runs-on: ubuntu-latest
environment: push
steps:
- name: Checkout self
uses: actions/checkout@v4
with:
path: self
- name: Validate chart
uses: actions/github-script@v7
env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.GH_APP_PEM }}
with:
script: |
const config = require('./self/.github/workflows/scripts/validateChart.js')
return await config({ core, context })
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- name: Checkout ${{ env.OWNER }}/${{ env.REPO }}
uses: actions/checkout@v4
with:
repository: ${{ env.OWNER }}/${{ env.REPO }}
ref: ${{ env.REF }}
path: source
- name: Package charts
uses: actions/github-script@v7
with:
script: |
const helm = require('./self/.github/workflows/scripts/packageChart.js')
return await helm({ core, glob, exec })
- name: Install packages
run: npm i octokit fs @octokit/core
- name: Update index and push files
uses: actions/github-script@v7
env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.GH_APP_PEM }}
with:
script: |
const generateToken = require('./self/.github/workflows/scripts/token.js')
const push = require('./self/.github/workflows/scripts/push.js')
const tokenPermissions = { contents: "write" } // required to push files
try {
const token = await generateToken({ core, fetch }, 'G-Research', 'charts', tokenPermissions )
return await push({ core, exec, context, fetch }, token )
} catch (error) {
core.notice(`Permission: ${JSON.stringify(tokenPermissions)}`)
return core.setFailed(`Unable to push ${context.payload.repository.owner.login}/${context.payload.repository.name}, please check token permissions.\n${error}`)
}