Skip to content

Commit

Permalink
Setup CI run
Browse files Browse the repository at this point in the history
Signed-off-by: Dhi Aurrahman <[email protected]>
  • Loading branch information
dio committed Jan 23, 2024
1 parent dbe518c commit 3e9adc2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and release
on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: build-and-release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-index:
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
path: gh-pages
ref: gh-pages
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.21.6
- uses: magefile/mage-action@6a5dcb5fe61f43d7c08a98bc3cf9bc63c308c08e # v3.0.0
with:
install-only: true
- uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- run: mage packistio
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- if: github.ref == 'refs/heads/main'
run: mage index https://github.com/tetratelabs/legacy-charts/releases/download/istio-
- if: github.ref == 'refs/heads/main'
uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d # v5.0.0
with:
repository: gh-pages
commit_message: Apply automatic update for install.sh
branch: gh-pages
commit_user_name: tetrate-ci
commit_user_email: [email protected]
commit_author: tetrate-ci[bot] <[email protected]>
file_pattern: '*.yaml'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store

/dist
/gh-pages
14 changes: 9 additions & 5 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,30 @@ func PackIstio(ctx context.Context) error {
// URL gives prefix for the tarballs. For example: https://github.com/tetratelabs/legacy-charts/releases/download.
func Index(ctx context.Context, url string) error {
dir := filepath.Join("dist")
if _, err := os.Stat(dir); err != nil {
fmt.Println("missing dist, nothing to do")
return nil
}
indexYAML := filepath.Join(dir, "index.yaml")
previousIndexYAML := filepath.Join("gh-pages", "index.yaml")
publishedIndexYAML := filepath.Join("gh-pages", "index.yaml")
args := []string{
"repo",
"index",
dir,
"--url", url,
}
if _, err := os.Stat(previousIndexYAML); err == nil {
args = append(args, "--merge", previousIndexYAML)
if _, err := os.Stat(publishedIndexYAML); err == nil {
args = append(args, "--merge", publishedIndexYAML)
}
if err := sh.Run(ctx, "helm", args...); err != nil {
return err
}
b, err := os.ReadFile(filepath.Join(dir, "index.yaml"))
b, err := os.ReadFile(indexYAML)
if err != nil {
return err
}
sanitized := strings.ReplaceAll(string(b), "istio-/", "istio-")
return os.WriteFile(indexYAML, []byte(sanitized), os.ModePerm)
return os.WriteFile(publishedIndexYAML, []byte(sanitized), os.ModePerm)
}

func packVersioned(ctx context.Context, version string) error {
Expand Down

0 comments on commit 3e9adc2

Please sign in to comment.