From 22885b655282751457da3b8c1bf58a8bc2f56ebb Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 19 Sep 2022 19:08:47 +0700 Subject: [PATCH] add reusable workflows Signed-off-by: Nikita Skrynnik --- .github/workflows/automerge.yaml | 20 +-------- .github/workflows/ci.yaml | 60 +++------------------------ .github/workflows/pr-for-updates.yaml | 20 ++------- 3 files changed, 11 insertions(+), 89 deletions(-) diff --git a/.github/workflows/automerge.yaml b/.github/workflows/automerge.yaml index de838d10..b314acd2 100644 --- a/.github/workflows/automerge.yaml +++ b/.github/workflows/automerge.yaml @@ -8,25 +8,9 @@ on: - 'ci' jobs: automerge-on-success: - name: Automerge - runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' && github.actor == 'nsmbot' }} - steps: - - name: Check out the code - uses: actions/checkout@v2 - - name: Fetch main - run: | - git remote -v - git fetch --depth=1 origin main - - name: Only allow go.mod and go.sum changes - run: | - find . -type f ! -name 'go.mod' ! -name 'go.sum' ! -name '*.yaml' ! -name '*.yml' -exec git diff --exit-code origin/main -- {} + - - name: Merge PR - uses: ridedott/merge-me-action@master - with: - GITHUB_LOGIN: nsmbot - ENABLED_FOR_MANUAL_CHANGES: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: networkservicemesh/.github/.github/workflows/automerge.yaml@main + automerge-otherwise: name: Automerge runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cd798b25..9366aa29 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,67 +12,19 @@ concurrency: jobs: yamllint: - name: yamllint - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - name: yaml-lint - uses: ibiqlik/action-yamllint@v1 - with: - config_file: .ci/yamllint.yml - strict: true + uses: networkservicemesh/.github/.github/workflows/yamllint.yaml@main shellcheck: - name: shellcheck - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: shellcheck - uses: fkautz/shell-linter@v1.0.1 + uses: networkservicemesh/.github/.github/workflows/shellcheck.yaml@main golangci-lint: - name: golangci-lint - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup Go - uses: actions/setup-go@v1 - with: - go-version: 1.16 - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.35 + uses: networkservicemesh/.github/.github/workflows/golangci-lint.yaml@main - excludeFmtErrorf: - name: exclude fmt.Errorf - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Exclude fmt.Errorf - run: | - if grep -r --include=*.go --exclude=*.pb.go fmt.Errorf . ; then - echo "Please use errors.Errorf (or errors.New or errors.Wrap or errors.Wrapf) as appropriate rather than fmt.Errorf" - exit 1 - fi + exclude-fmt-errorf: + uses: networkservicemesh/.github/.github/workflows/exclude-fmt-errorf.yaml@main checkgomod: - name: check go.mod and go.sum - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v1 - with: - go-version: 1.16 - - run: go mod tidy - - name: Check for changes in go.mod or go.sum - run: | - git diff --name-only --exit-code go.mod || ( echo "Run go tidy" && false ) - git diff --name-only --exit-code go.sum || ( echo "Run go tidy" && false ) + uses: networkservicemesh/.github/.github/workflows/checkgomod.yaml@main packet: name: packet (CNI ${{ matrix.CNI }}) diff --git a/.github/workflows/pr-for-updates.yaml b/.github/workflows/pr-for-updates.yaml index ed6ef4d8..86c9ea96 100644 --- a/.github/workflows/pr-for-updates.yaml +++ b/.github/workflows/pr-for-updates.yaml @@ -6,20 +6,6 @@ on: - update/** jobs: auto-pull-request: - name: Pull Request on update/* Branch Push - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Construct PR message - run: | - PULL_REQUEST_BODY=$(git log --pretty='format:%B' -1 | sed '/^$/d;$d' | sed 's/#/# /g') - echo "$PULL_REQUEST_BODY" - echo "PULL_REQUEST_BODY<> $GITHUB_ENV - echo "$PULL_REQUEST_BODY" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - name: pull-request-action - uses: vsoch/pull-request-action@1.0.12 - env: - GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} - BRANCH_PREFIX: "update/" - PULL_REQUEST_BRANCH: "main" + uses: networkservicemesh/.github/.github/workflows/pr-for-updates.yaml@main + secrets: + token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}