Skip to content

Commit

Permalink
Revert accidental commit
Browse files Browse the repository at this point in the history
Signed-off-by: mordivgor <[email protected]>
  • Loading branch information
radoslaw-sz committed Oct 25, 2024
1 parent dd640f3 commit a8ad706
Show file tree
Hide file tree
Showing 41 changed files with 2,702 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/api-breaking-changes-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: API Breaking Changes (comment)

on:
workflow_run:
workflows:
- 'API Breaking Changes (Trigger)'
types:
- completed

jobs:
setup:
name: Add values from previous step
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
# "If you specify the access for any of these scopes, all of those that are not specified are set to none."
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
actions: read # Access cache
outputs:
git-ref: ${{ steps.event.outputs.GIT_REF }}
pr-number: ${{ steps.event.outputs.PR_NUMBER }}
action: ${{ steps.event.outputs.ACTION }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
- name: 'Download artifacts'
# Fetch output (zip archive) from the workflow run that triggered this workflow.
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "preview-spec"
})[0];
if (matchArtifact === undefined) {
throw TypeError('Build Artifact not found!');
}
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data));
- name: 'Accept event from first stage'
run: unzip preview-spec.zip event.json

- name: Read Event into ENV
id: event
run: |
echo PR_NUMBER=$(jq '.number | tonumber' < event.json) >> $GITHUB_OUTPUT
echo ACTION=$(jq --raw-output '.action | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT
echo GIT_REF=$(jq --raw-output '.pull_request.head.sha | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT
- name: DEBUG - Print Job Outputs
if: ${{ runner.debug }}
run: |
echo "PR number: ${{ steps.event.outputs.PR_NUMBER }}"
echo "Git Ref: ${{ steps.event.outputs.GIT_REF }}"
echo "Action: ${{ steps.event.outputs.ACTION }}"
cat event.json
- name: Get Comment
id: get-comment
run: |
unzip preview-spec.zip comment.md
ls
grep
add-comment:
name: Write comment about issues
needs:
- setup
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4

# Identify comment to be updated
- name: Find comment for API Changes
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3
id: find-comment
with:
issue-number: ${{ needs.setup.outputs.pr-number }}
comment-author: 'github-actions[bot]'
body-includes: API changes
direction: last

- name: Create or Update Comment with API Changes
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: comment.md
edit-mode: replace
56 changes: 56 additions & 0 deletions .github/workflows/api-breaking-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: API Breaking Changes (Trigger)
on:
pull_request:
types: [opened, synchronize, reopened, closed]
paths:
- '**/openapi.yaml'

jobs:
get-backstage-changes:
env:
NODE_OPTIONS: --max-old-space-size=4096
name: Build PR image
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Fetch the commit that's merged into the base rather than the target ref
# This will let us diff only the contents of the PR, without fetching more history
ref: 'refs/pull/${{ github.event.pull_request.number }}/merge'
- name: fetch base
run: git fetch --depth 1 origin ${{ github.base_ref }}

- name: setup-node
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org/

- name: yarn install
uses: backstage/actions/yarn-install@25145dd4117d50e1da9330e9ed2893bc6b75373e # v0.6.15
with:
cache-prefix: linux-v20

- name: breaking changes check
run: |
yarn backstage-repo-tools repo schema openapi diff --since origin/${{ github.base_ref }} > comment.md
- name: clone artifacts to current directory
run: |
cat ${{ github.event_path }} > event.json
- name: Upload Artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: preview-spec
path: |
comment.md
event.json
retention-days: 2
overwrite: true
23 changes: 23 additions & 0 deletions .github/workflows/automate_area-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Automate area labels
on:
- pull_request_target

permissions:
contents: read

jobs:
triage:
permissions:
contents: read # for actions/labeler to determine modified files
pull-requests: write # for actions/labeler to add labels to PRs
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
sync-labels: true
46 changes: 46 additions & 0 deletions .github/workflows/automate_changeset_feedback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Automate changeset feedback
on:
pull_request_target:
branches: ['master']

permissions:
pull-requests: write
actions: none
checks: none
contents: none
deployments: none
issues: none
packages: none
pages: none
repository-projects: none
security-events: none
statuses: none

jobs:
feedback:
# prevent running towards forks and version packages
if: github.repository == 'backstage/backstage' && github.event.pull_request.user.login != 'backstage-service'
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Fetch the commit that's merged into the base rather than the target ref
# This will let us diff only the contents of the PR, without fetching more history
ref: 'refs/pull/${{ github.event.pull_request.number }}/merge'
- name: fetch base
run: git fetch --depth 1 origin ${{ github.base_ref }}
- uses: backstage/actions/changeset-feedback@25145dd4117d50e1da9330e9ed2893bc6b75373e # v0.6.15
name: Generate feedback
with:
diff-ref: 'origin/master'
marker: <!-- changeset-feedback -->
issue-number: ${{ github.event.pull_request.number }}
bot-username: backstage-goalie[bot]
app-id: ${{ secrets.BACKSTAGE_GOALIE_APPLICATION_ID }}
private-key: ${{ secrets.BACKSTAGE_GOALIE_PRIVATE_KEY }}
installation-id: ${{ secrets.BACKSTAGE_GOALIE_INSTALLATION_ID }}
68 changes: 68 additions & 0 deletions .github/workflows/automate_merge_message.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Automate merge message
on:
pull_request_target:
branches: ['master']
types: ['closed']

permissions:
pull-requests: write
actions: none
checks: none
contents: none
deployments: none
issues: none
packages: none
pages: none
repository-projects: none
security-events: none
statuses: none

jobs:
message:
# prevent running towards forks, and only run on merged PRs
if: github.repository == 'backstage/backstage' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: '${{ github.event.pull_request.merge_commit_sha }}'

- name: fetch head & base
run: git fetch --depth 1 origin ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }}

# We avoid using the in-source script since this workflow has elevated permissions that we don't want to expose
- name: Generate Message
id: generate-message
run: |
rm -f generate.js
wget -O generate.js https://raw.githubusercontent.com/backstage/backstage/master/scripts/generate-merge-message.js 1>&2
node generate.js ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > message.txt
- name: Post Message
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
ISSUE_NUMBER: ${{ github.event.pull_request.number }}
with:
script: |
const owner = "backstage";
const repo = "backstage";
const body = require('fs').readFileSync('message.txt', 'utf8').trim();
const issue_number = Number(process.env.ISSUE_NUMBER);
if (!body) {
console.log(`skipping comment for #${issue_number}`);
return;
}
console.log(`creating comment for #${issue_number}`);
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
42 changes: 42 additions & 0 deletions .github/workflows/automate_stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Automate staleness
on:
workflow_dispatch:
schedule:
- cron: '*/10 * * * *' # run every 10 minutes as it also removes labels.

permissions:
contents: read

jobs:
stale:
permissions:
issues: write # for actions/stale to close stale issues
pull-requests: write # for actions/stale to close stale PRs
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
id: stale
with:
stale-issue-message: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
days-before-issue-stale: 60
days-before-issue-close: 7
exempt-issue-labels: plugin,after-vacations,will-fix,bep
stale-issue-label: stale
stale-pr-message: >
This PR has been automatically marked as stale because it has not had
recent activity from the author. It will be closed if no further activity occurs.
If the PR was closed and you want it re-opened, let us know
and we'll re-open the PR so that you can continue the contribution!
days-before-pr-stale: 14
days-before-pr-close: 7
exempt-pr-labels: after-vacations,will-fix
stale-pr-label: stale
operations-per-run: 100
47 changes: 47 additions & 0 deletions .github/workflows/ci-noop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# NO-OP placeholder that always passes for other paths
# This is here so that we're able to set the status check as required

name: CI Void
on:
pull_request:
paths:
- 'microsite/**'
- 'beps/**'

permissions:
contents: read

jobs:
# The verify jobs runs all the verification that doesn't require a
# diff towards master, since it takes some time to fetch that.
verify-noop:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x, 22.x]

name: Verify ${{ matrix.node-version }}
steps:
# - name: Harden Runner
# uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
# with:
# egress-policy: audit

- run: echo NOOP

test-noop:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x, 22.x]

name: Test ${{ matrix.node-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- run: echo NOOP
Loading

0 comments on commit a8ad706

Please sign in to comment.