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

Add update-hack knobots action #214

Closed
wants to merge 1 commit into from
Closed
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
155 changes: 155 additions & 0 deletions .github/workflows/auto-update-hack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Copyright 2022 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

##
## This file is auto-generated from actions/update-community/auto-apply.yaml
## by ./cmd/gen-actions
##

name: Update hack/upstream

on:
schedule:
- cron: '0 1,13 * * 1-5' # 6am/pm Pacific on weekdays

workflow_dispatch:
inputs:
only-repo:
required: false
description: "Only sync a single repo (exact match)?"
reason:
description: "Justification?"
required: true


jobs:
meta:
runs-on: ubuntu-latest
outputs:
includes: ${{ steps.load-matrix.outputs.includes }}
names: ${{ steps.load-matrix.outputs.names }}

steps:
- name: Check out knobots configuration
uses: actions/checkout@v3

- name: Calculate affected repos
id: load-matrix
uses: "./actions/calculate-matrix"
with:
action-name: community
only-repo: ${{ github.event.inputs.only-repo }}

apply-change:
name: "Apply Change" # TODO: from metadata?
needs: meta
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
name: ${{ fromJson(needs.meta.outputs.names) }}
include: ${{ fromJson(needs.meta.outputs.includes) }}
steps:

- name: Checkout config code
uses: actions/checkout@v3
with:
path: config

- name: Checkout ${{ matrix.name }} code
uses: actions/checkout@v3
with:
path: main
repository: ${{ matrix.name }}

- name: Checkout knative/hack code
uses: actions/checkout@v3
with:
path: meta
repository: knative/hack


# This is required because the branch setting might be empty (to infer a default), so
# after checkout we fetch what the checkout action decided to check out.
- name: Infer branch from checkout
id: inferbranch
run: |
cd main
echo "::set-output name=branch::$(git branch --show-current)"

- name: Apply work
id: work
uses: "./config/actions/update-hack"
with:
repo: ${{ matrix.name }}
organization: ${{ matrix.meta-organization }}
include: ${{ matrix.include }}

- name: Create Pull Request
id: cpr
if: ${{ env.create_pr == 'true' }}
uses: peter-evans/create-pull-request@v4
with:
# Who to look like
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
committer: "Knative Automation <[email protected]>"
author: "Knative Automation <[email protected]>"

# Where to stage the change
push-to-fork: ${{ matrix.fork }}
branch: auto-updates/update-hack-${{ steps.inferbranch.outputs.branch }}
signoff: true
delete-branch: true

# What labels to add
labels: ${{ env.pr_labels }}

# Note this is hard-coded based on the added repos in main.go
path: main

commit-message: |
Update hack/upstream files

${{ steps.work.outputs.log }}

title: "[${{ steps.inferbranch.outputs.branch }}] Update hack/upstream files"
body: |
${{ github.event.inputs.reason || 'Cron' }} -${{ github.actor }}

/cc ${{ matrix.assignees }}
/assign ${{ matrix.assignees }}

Produced by: ${{ github.repository }}/actions/update-hack

Details:
```
${{ steps.work.outputs.log }}
```

- name: Report error
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() }}
env:
SLACK_ICON: http://github.com/knative-automation.png?size=48
SLACK_USERNAME: knative-automation
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

SLACK_CHANNEL: ${{ matrix.channel }}
SLACK_COLOR: '#8E1600'
MSG_MINIMAL: 'true'
SLACK_TITLE: "[${{ steps.inferbranch.outputs.branch }}] Update hack/upstream files for ${{ matrix.name }} has failed."
SLACK_MESSAGE: |
For detailed logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
${{ github.event.inputs.reason || 'Cron' }} -${{ github.actor }}
1 change: 0 additions & 1 deletion actions/update-community/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ if [ -f "${GITHUB_WORKSPACE}/meta/${FILE}" ]; then
else
echo "Could not find ${FILE}, skipping"
fi
# TODO: copy other files over, like CODE-OF-CONDUCT.md

# Ensure files have the same owner as the checkout directory.
# See https://github.com/knative-sandbox/knobots/issues/79
Expand Down
19 changes: 19 additions & 0 deletions actions/update-hack/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
32 changes: 32 additions & 0 deletions actions/update-hack/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2021 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: "Update hack/upstream in repositories"
description: "Updates hack/upstream folders in Knative repositories."
branding:
icon: users
color: green
inputs:
organization:
required: true
description: "The organization that the target repo belongs to"
outputs:
log:
description: "Log of changes"
runs:
using: 'docker'
image: 'Dockerfile'
env:
ORGANIZATION: ${{ inputs.organization }}

31 changes: 31 additions & 0 deletions actions/update-hack/auto-apply.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2021 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

shortName: hack
title: "Update hack"

# No special inputs needed.

prTitle: "[${{ steps.inferbranch.outputs.branch }}] Update hack/upstream files"
repos:
main:
name: "${{ matrix.name }}"
meta:
name: "knative/hack"

commitMessage: |
Update hack files

${{ steps.work.outputs.log }}

47 changes: 47 additions & 0 deletions actions/update-hack/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Copyright 2022 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

log=""
create_pr="false"
# The label used for Prow Tide to auto-merge PRs that pass all the required presubmit checks.
# Must be configured in Prow to be effective. Example:
# https://github.com/knative/test-infra/blob/66d6a1f645ff585bfd1bce0eee0cb3446c7405b9/prow/config.yaml#L168
pr_labels="skip-review"

apt update && apt install git -y

mkdir -p "${GITHUB_WORKSPACE}/main/hack/upstream"
cp -r "${GITHUB_WORKSPACE}/meta/" "${GITHUB_WORKSPACE}/main/hack/upstream"
echo "Copying ${GITHUB_WORKSPACE}/meta/ -> ${GITHUB_WORKSPACE}/main/hack/upstream"
popd ${GITHUB_WORKSPAeCE}/main
if [[ -z "$(git status --porcelain)" ]]; then
echo "hack/upstream is up to date. Moving on"
else
create_pr="true"
echo "hack/upstream is out of to date. Opening a PR to sync latest changes"
fi
pushd

# Ensure files have the same owner as the checkout directory.
# See https://github.com/knative-sandbox/knobots/issues/79
chown -R --reference=. .

echo "create_pr=${create_pr}" >> $GITHUB_ENV
echo "pr_labels=${pr_labels}" >> $GITHUB_ENV

echo "::set-output name=log::${log}"
56 changes: 56 additions & 0 deletions hack-exclude.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Generated by running for entry in $(yq .[].name repos.yaml); do echo "- \"$entry\""; done
# After that command delete the knative/test-infra entry
- "knative/pkg"
- "knative/caching"
- "knative/networking"
- "knative/serving"
- "knative/eventing"
- "knative/operator"
- "knative/test-infra"
- "knative/actions"
- "knative/docs"
- "knative/client"
- "knative/client-pkg"
- "knative/homebrew-client"
- "knative/release"
- "knative/hack"
- "knative/infra"
- "knative-sandbox/knobots"
- "knative-sandbox/.github"
- "knative-sandbox/reconciler-test"
- "knative-sandbox/sample-controller"
- "knative-sandbox/sample-source"
- "knative-sandbox/control-protocol"
- "knative-sandbox/discovery"
- "knative-sandbox/eventing-autoscaler-keda"
- "knative-sandbox/eventing-ceph"
- "knative-sandbox/eventing-couchdb"
- "knative-sandbox/eventing-github"
- "knative-sandbox/eventing-gitlab"
- "knative-sandbox/eventing-kafka"
- "knative-sandbox/eventing-kafka-broker"
- "knative-sandbox/eventing-kogito"
- "knative-sandbox/eventing-natss"
- "knative-sandbox/eventing-rabbitmq"
- "knative-sandbox/eventing-redis"
- "knative-sandbox/net-contour"
- "knative-sandbox/net-kourier"
- "knative-sandbox/net-istio"
- "knative-sandbox/net-http01"
- "knative-sandbox/net-certmanager"
- "knative-sandbox/net-gateway-api"
- "knative-sandbox/kperf"
- "knative-sandbox/homebrew-kn-plugins"
- "knative-sandbox/kn-plugin-admin"
- "knative-sandbox/kn-plugin-diag"
- "knative-sandbox/kn-plugin-event"
- "knative-sandbox/kn-plugin-func"
- "knative-sandbox/kn-plugin-migration"
- "knative-sandbox/kn-plugin-operator"
- "knative-sandbox/kn-plugin-quickstart"
- "knative-sandbox/kn-plugin-sample"
- "knative-sandbox/kn-plugin-service-log"
- "knative-sandbox/kn-plugin-source-kafka"
- "knative-sandbox/kn-plugin-source-kamelet"
- "knative-sandbox/container-freezer"
- "vmware-tanzu/sources-for-knative"