Skip to content

Commit

Permalink
Merge pull request #654 from ergebnis/feature/reuse
Browse files Browse the repository at this point in the history
Enhancement: Reuse composite actions from `ergebnis/.github`
  • Loading branch information
localheinz committed Jan 24, 2022
2 parents ef7f24b + c02d8e9 commit 79ba4d5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 117 deletions.
70 changes: 6 additions & 64 deletions .github/workflows/merge.yaml
Expand Up @@ -25,81 +25,23 @@ jobs:
steps:
- name: "Request review from @ergebnis-bot"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/request-review@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0];
const reviewers = [
"ergebnis-bot",
];
try {
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
pull_number: pullRequest.number,
repo: context.repo.repo,
reviewers: reviewers,
});
} catch (error) {
core.setFailed(error.message);
}
reviewer: "ergebnis-bot"

- name: "Assign @ergebnis-bot"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/add-assignee@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0];
const assignees = [
"ergebnis-bot",
];
try {
await github.rest.issues.addAssignees({
assignees: assignees,
issue_number: pullRequest.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
} catch (error) {
core.setFailed(error.message);
}
assignee: "ergebnis-bot"

- name: "Approve pull request"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/approve@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0];
try {
await github.rest.pulls.createReview({
event: "APPROVE",
owner: context.repo.owner,
pull_number: pullRequest.number,
repo: context.repo.repo,
});
} catch (error) {
core.setFailed(error.message);
}

- name: "Merge pull request"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/merge@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0];
try {
await github.rest.pulls.merge({
merge_method: "merge",
owner: context.repo.owner,
pull_number: pullRequest.number,
repo: context.repo.repo,
});
} catch (error) {
core.setFailed(error.message);
}
19 changes: 1 addition & 18 deletions .github/workflows/release.yaml
Expand Up @@ -14,24 +14,7 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- name: "Determine tag"
run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"

- name: "Create release"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/release/create@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
try {
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
} catch (error) {
core.setFailed(error.message);
}
36 changes: 1 addition & 35 deletions .github/workflows/triage.yaml
Expand Up @@ -15,40 +15,6 @@ jobs:

steps:
- name: "Add labels based on branch name"
uses: "actions/github-script@v5"
uses: "ergebnis/.github/actions/github/pull-request/add-label-based-on-branch-name@1.3.2"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const branchPrefixLabels = {
feature: "enhancement",
fix: "bug",
};
const pullRequest = context.payload.pull_request;
const branchName = pullRequest.head.ref;
const matches = branchName.match(new RegExp('^([^/]+)\/'));
if (!matches instanceof Array) {
return;
}
if (!branchPrefixLabels.hasOwnProperty(matches[1])) {
return;
}
const label = branchPrefixLabels[matches[1]];
try {
await github.rest.issues.addLabels({
issue_number: pullRequest.number,
labels: [
label,
],
owner: context.repo.owner,
repo: context.repo.repo,
});
} catch (error) {
core.setFailed(error.message);
}

0 comments on commit 79ba4d5

Please sign in to comment.