Skip to content

Commit

Permalink
Combine ci and release workflows
Browse files Browse the repository at this point in the history
This ensures that if a commit doesn't pass all of lint, test, docs and
sync-readme steps then it will not be released.
  • Loading branch information
hashhar committed Mar 18, 2022
1 parent 9a7d2b2 commit 690534f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 67 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This workflow:
# - lints the chart, runs tests and verifies documentation is up to date
# Additionally if the event isn't a pull-request (and hence a merge/push to main):
# - sync README to gh-pages branch
# - release a new chart version if the version isn't already released
name: CI

on:
Expand Down Expand Up @@ -67,3 +72,61 @@ jobs:
else
echo "charts/trino/README.md is in-sync with chart"
fi
# Everything above is CI, everything here and below is for releases and runs only on non-pull-request events
sync-readme:
needs: [lint, test, docs]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout main
uses: actions/checkout@v2
with:
path: main
- name: Checkout gh-pages
uses: actions/checkout@v2
with:
ref: gh-pages
path: gh-pages
- name: Copy all README files from main to gh-pages
run: |
cd main
# cp --parents preserves directory structure
find . -name 'README.md' -exec cp --parents '{}' "../gh-pages/" ';'
- name: Commit changes to gh-pages and push
run: |
cd gh-pages
git add .
git config user.name "GITHUB_ACTOR"
git config user.email "[email protected]"
# Commit only if changes exist to avoid failure in this step
git diff-index --quiet HEAD || git commit --signoff -m "Sync READMEs from main"
git push
release:
needs: [lint, test, docs, sync-readme]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v2
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Build release changelog
id: github_release
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
configuration: '.github/changelog-config.json'
outputFile: ${{ runner.temp }}/CHANGELOG.md
- name: Inspect changelog
run: cat ${{ runner.temp }}/CHANGELOG.md
- name: Release charts
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NOTES_FILE: ${{ runner.temp }}/CHANGELOG.md
# If we didn't bump the chart version then we can skip the release
CR_SKIP_EXISTING: true
67 changes: 0 additions & 67 deletions .github/workflows/release.yaml

This file was deleted.

0 comments on commit 690534f

Please sign in to comment.