Skip to content

Auto Nightly CI

Auto Nightly CI #967

name: Auto Nightly CI
on:
schedule:
# run 4:00 am each day in shanghai timezone
# cron by UTC, shanghai timezone = UTC + 8
- cron: "0 20 * * *"
workflow_dispatch:
inputs:
ref:
description: 'sha, tag, branch'
required: true
default: main
jobs:
get_ref:
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.result.outputs.ref }}
steps:
- name: Get Ref
id: get_ref
run: |
if ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "call by self workflow_dispatch"
echo ::set-output name=ref::${{ github.event.inputs.ref }}
else
echo "call by event: ${{ github.event_name }}"
# use main sha for ci image tag
echo ::set-output name=ref::main
fi
# some event, the tag is not sha, so checkout it and get sha
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
ref: ${{ steps.get_ref.outputs.ref }}
- name: Result Ref
id: result
run: |
ref=$( git show -s --format='format:%H' )
echo ::set-output name=ref::${ref}
call_unitest:
needs: get_ref
# forbid to specify version for local workflow, GITHUB_REF Same as the caller workflow
uses: ./.github/workflows/lint-golang.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
# reusable workflow can not see secrets, so have to pass from outside
secrets: inherit
call_build_ci_image:
needs: [call_unitest, get_ref]
# get image:${{ needs.get_ref.outputs.ref }} and image-ci:${{ needs.get_ref.outputs.ref }}
uses: ./.github/workflows/build-image-ci.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
push: false
# reusable workflow can not see secrets, so have to pass from outside
secrets: inherit
call_test_chart:
needs: get_ref
# forbid to specify version for local workflow, GITHUB_REF Same as the caller workflow
uses: ./.github/workflows/call-lint-chart.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
# reusable workflow can not see secrets, so have to pass from outside
secrets: inherit
call_release_chart:
needs: [call_test_chart, get_ref]
uses: ./.github/workflows/call-release-chart.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
submit: false
# reusable workflow can not see secrets, so have to pass from outside
secrets: inherit
call_e2e_test:
runs-on: ubuntu-latest
needs: [call_build_ci_image, call_release_chart, get_ref]
steps:
- name: Prepare
run: |
echo "ref: ${{ needs.get_ref.outputs.ref }}"
echo "===== image"
echo "ci image tag: ghcr.io/${{ github.repository }}/controllerimage-ci:${{ needs.call_build_ci_image.outputs.imageTag }}"
echo "ci race image tag: ghcr.io/${{ github.repository }}/controllerimage-ci:${{ needs.call_build_ci_image.outputs.imageTag }}-race"
echo "====== chart"
echo "chart package artifact: ${{ needs.call_release_chart.outputs.artifact }}"
- name: Download Chart Artifact
uses: actions/[email protected]
with:
name: ${{ needs.call_release_chart.outputs.artifact }}
path: chart-package/