Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci/cd: simplify and refactor workflows #246

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: CD

concurrency:
group: push_on_master
cancel-in-progress: false

on:
push:
branches:
- master
paths-ignore:
- 'README.md'
- 'LICENSE'

env:
CHART_NAME: "application"

jobs:
call-ci-workflow:
uses: ./.github/workflows/ci.yaml
secrets: inherit
with:
skip-slack-notification: true

publish:
name: Publish Chart
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [call-ci-workflow]

steps:
- uses: actions/checkout@v3
with:
persist-credentials: false

- name: Generate New Tag
id: generate_tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DEFAULT_BUMP: patch
DRY_RUN: true

- name: Update chart version
env:
VERSION: ${{ steps.generate_tag.outputs.new_tag }}
run: |
make bump-chart

- name: Publish Helm chart
uses: stefanprodan/helm-gh-pages@master
with:
branch: master
repository: stakater-charts
target_dir: docs
token: ${{ secrets.STAKATER_GITHUB_TOKEN }}
charts_dir: .
charts_url: https://stakater.github.io/stakater-charts
owner: stakater
linting: off
commit_username: stakater-user
commit_email: [email protected]

bump-version:
name: Bump Version
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [publish]

steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0

- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "stakater-user"
git status
git add application/Chart.yaml
git commit -m "[skip-ci] Update artifacts"

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.STAKATER_GITHUB_TOKEN }}
branch: ${{ inputs.RELEASE_BRANCH }}

- name: Push latest tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch

notify:
name: Notify Results
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [publish, bump-version]
if: always()

steps:
- id: workflow
name: Compute workflow status
run: |
if [ "${{ contains(needs.*.result, 'failure') }}" = "true" ]; then
echo "status=failure" >> "$GITHUB_OUTPUT"
else
echo "status=success" >> "$GITHUB_OUTPUT"
fi

- name: Notify Slack
uses: 8398a7/action-slack@v3
if: always()
with:
status: ${{ steps.workflow.outputs.status }}
fields: repo,author,action,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.STAKATER_DELIVERY_SLACK_WEBHOOK }}
100 changes: 100 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: CI

on:
workflow_call:
inputs:
skip-slack-notification:
description: Whether to skip sending a notification to Slack.
required: true
type: boolean

pull_request_target:
branches:
- master
paths-ignore:
- 'README.md'
- 'LICENSE'

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5

if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"

steps:
- uses: actions/checkout@v3
- uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: helm lint application

unittest:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 5

if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"

steps:
- uses: actions/checkout@v3
- uses: d3adb5/helm-unittest-action@v2
with:
charts: application

dry-run:
name: Install Dry Run
runs-on: ubuntu-latest
timeout-minutes: 10

if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"

steps:
- uses: actions/checkout@v3
- uses: helm/[email protected]
- uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: |
helm install --debug --dry-run test-release application \
-f application/values-test.yaml

notify:
name: Notify Results
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [lint, unittest, dry-run]
if: always() && ! contains(toJSON(github.event.commits.*.message), '[skip-ci]')


steps:
- id: workflow
name: Compute workflow status
run: |
if [ "${{ contains(needs.*.result, 'failure') }}" = "true" ]; then
echo "status=failure" >> "$GITHUB_OUTPUT"
else
echo "status=success" >> "$GITHUB_OUTPUT"
fi

- name: Comment on PR
uses: mshick/add-pr-comment@v2
with:
repo-token: ${{ secrets.STAKATER_GITHUB_TOKEN }}
status: ${{ steps.workflow.outputs.status }}
message-success: >-
@${{ github.actor }} Your PR has passed the status checks! :tada:
message-failure: >-
@${{ github.actor }} Yikes! You better fix your PR before anyone
else finds out! It seems some status checks have failed.
allow-repeats: false

- name: Notify Slack
uses: 8398a7/action-slack@v3
if: always() && ! inputs.skip-slack-notification
with:
status: ${{ steps.workflow.outputs.status }}
fields: repo,author,action,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.STAKATER_DELIVERY_SLACK_WEBHOOK }}
100 changes: 0 additions & 100 deletions .github/workflows/pull_request.yaml

This file was deleted.

Loading