From 1d67a32f4dd3f11f8e9eddb13e4b345ea2dac1ec Mon Sep 17 00:00:00 2001 From: Sam <109683132+kernelsam@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:31:41 -0800 Subject: [PATCH 1/3] #9 change name to github --- .github/linters/.markdown-lint.yml | 4 +- .github/workflows/docker-build-container.yaml | 3 +- .project | 2 +- CODE_OF_CONDUCT.md | 20 +++---- CONTRIBUTING.md | 58 +++++++++++-------- Makefile | 2 +- README.md | 52 ++++++++--------- action.yml | 14 ++--- build/docker/Dockerfile | 14 ++--- ...late_github_action_slack_notification.yml} | 6 +- go.mod | 2 +- main.go | 2 +- 12 files changed, 94 insertions(+), 85 deletions(-) rename deployment/{git-actions/template_git_action_slack_notification.yml => github-actions/template_github_action_slack_notification.yml} (83%) diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml index aec8fd5..40ed110 100644 --- a/.github/linters/.markdown-lint.yml +++ b/.github/linters/.markdown-lint.yml @@ -1,3 +1 @@ -{ - "line-length": false -} +{ "line-length": false } diff --git a/.github/workflows/docker-build-container.yaml b/.github/workflows/docker-build-container.yaml index 788d0d9..cb58be3 100644 --- a/.github/workflows/docker-build-container.yaml +++ b/.github/workflows/docker-build-container.yaml @@ -19,7 +19,8 @@ jobs: - name: build docker image uses: senzing-factory/github-action-docker-buildx-build@v1 with: - build-options: "--build-arg \"GITHUB_HEAD_REF=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}\" \ + build-options: + "--build-arg \"GITHUB_HEAD_REF=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}\" \ --build-arg \"GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME}\" " context: build/docker image-repository: senzing-factory/${{ steps.repo-basename.outputs.repo }} diff --git a/.project b/.project index 5490b14..386f828 100644 --- a/.project +++ b/.project @@ -1,4 +1,4 @@ - git-action-slack-notification + github-action-slack-notification diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 0dc166a..2515417 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db50261..061a138 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,40 +2,40 @@ Welcome to the project! -We encourage contribution in a manner consistent with the [Code of Conduct](CODE_OF_CONDUCT.md). +We encourage contribution in a manner consistent with the [Code of Conduct]. The following will guide you through the process. There are a number of ways you can contribute: -1. [Asking questions](#questions) -1. [Requesting features](#feature-requests) -1. [Reporting bugs](#bug-reporting) -1. [Contributing code or documentation](#contributing-code-or-documentation) +1. [Asking questions] +1. [Requesting features] +1. [Reporting bugs] +1. [Contributing code or documentation] ## License Agreements If your contribution modifies the git repository, the following agreements must be established. -*Note:* License agreements are only needed for adding, modifying, and deleting artifacts kept within the repository. +_Note:_ License agreements are only needed for adding, modifying, and deleting artifacts kept within the repository. In simple terms, license agreements are needed before pull requests can be accepted. A license agreement is not needed for submitting feature request, bug reporting, or other project management. ### Individual Contributor License Agreement In order to contribute to this repository, an -[Individual Contributor License Agreement (ICLA)](.github/senzing-individual-contributor-license-agreement.pdf) +[Individual Contributor License Agreement (ICLA)] must be completed, submitted and accepted. ### Corporate Contributor License Agreement If the contribution to this repository is on behalf of a company, a -[Corporate Contributor License Agreement (CCLA)](.github/senzing-corporate-contributor-license-agreement.pdf) +[Corporate Contributor License Agreement (CCLA)] must also be completed, submitted and accepted. ### Project License Agreement The license agreement for this repository is stated in the -[LICENSE](LICENSE) file. +[LICENSE] file. ## Questions @@ -50,7 +50,7 @@ TODO: Instead, use ??? All feature requests are "GitHub issues". To request a feature, create a -[GitHub issue](https://help.github.com/articles/creating-an-issue/) +[GitHub issue] in this repository. When creating an issue, there will be a choice to create a "Bug report" or a "Feature request". @@ -59,11 +59,8 @@ Choose "Feature request". ## Bug Reporting All bug reports are "GitHub issues". -Before reporting on a bug, check to see if it has -[already been reported](https://github.com/search?q=+is%3Aissue+user%3Asenzing). -To report a bug, create a -[GitHub issue](https://help.github.com/articles/creating-an-issue/) -in this repository. +Before reporting on a bug, check to see if it has [already been reported]. +To report a bug, create a [GitHub issue] in this repository. When creating an issue, there will be a choice to create a "Bug report" or a "Feature request". Choose "Bug report". @@ -71,8 +68,8 @@ Choose "Bug report". ## Contributing code or documentation To contribute code or documentation to the repository, you must have -[License Agreements](#license-agreements) in place. -This needs to be complete before a [Pull Request](#pull-requests) can be accepted. +[License Agreements] in place. +This needs to be complete before a [Pull Request] can be accepted. ### Setting up a development environment @@ -82,8 +79,8 @@ These variables may be modified, but do not need to be modified. The variables are used throughout the installation procedure. ```console -export GIT_ACCOUNT=senzing -export GIT_REPOSITORY=template-docker +export GIT_ACCOUNT=senzing-factory +export GIT_REPOSITORY=github-action-slack-notification ``` Synthesize environment variables. @@ -115,10 +112,23 @@ TODO: ### Pull Requests -Code in the master branch is modified via GitHub pull request. -Follow GitHub's -[Creating a pull request from a branch](https://help.github.com/articles/creating-a-pull-request/) -or -[Creating a pull request from a fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) instructions. +Code in the main branch is modified via GitHub pull request. +Follow GitHub's [Creating a pull request from a branch] or +[Creating a pull request from a fork] instructions. Accepting pull requests will be at the discretion of Senzing, Inc. and the repository owner(s). + +[already been reported]: https://github.com/search?q=+is%3Aissue+user%3Asenzing +[Asking questions]: #questions +[Code of Conduct]: CODE_OF_CONDUCT.md +[Contributing code or documentation]: #contributing-code-or-documentation +[Corporate Contributor License Agreement (CCLA)]: .github/senzing-corporate-contributor-license-agreement.pdf +[Creating a pull request from a branch]: https://help.github.com/articles/creating-a-pull-request/ +[Creating a pull request from a fork]: https://help.github.com/articles/creating-a-pull-request-from-a-fork/ +[GitHub issue]: https://help.github.com/articles/creating-an-issue/ +[Individual Contributor License Agreement (ICLA)]: .github/senzing-individual-contributor-license-agreement.pdf +[LICENSE]: LICENSE +[License Agreements]: #license-agreements +[Pull Request]: #pull-requests +[Reporting bugs]: #bug-reporting +[Requesting features]: #feature-requests diff --git a/Makefile b/Makefile index 3c78991..ec6cf04 100755 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ GIT_VERSION := $(shell git describe --always --tags --long --dirty | sed -e 's/\ # Docker variables DOCKER_IMAGE_TAG ?= $(GIT_REPOSITORY_NAME):$(GIT_VERSION) -DOCKER_IMAGE_NAME := senzing/git-action-slack-notification +DOCKER_IMAGE_NAME := senzing-factory/github-action-slack-notification # ------------- # TASKS diff --git a/README.md b/README.md index b78a5c4..ca339d4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Git Action Slack Notification +# GitHub Action Slack Notification Git Action to send messages to Slack. This action can be used to send message about the status of a Git Action workflow. @@ -6,28 +6,28 @@ Git Action to send messages to Slack. This action can be used to send message ab This action can be used after any other action. Below is simple example on using it: -1\. Create a `.github/workflows/git-action-slack-notification.yml` +1\. Create a `.github/workflows/github-action-slack-notification.yml` -2\. Add the following properties to `git-action-slack-notification.yml` file +2\. Add the following properties to `github-action-slack-notification.yml` file ```yaml on: push name: Slack Notification Demo jobs: - slackNotification: - name: Slack Notification Demo - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master + slackNotification: + name: Slack Notification Demo + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - name: Slack Notification Demo - uses: senzing/git-action-slack-notification@1.0.0 + uses: senzing-factory/github-action-slack-notification@1.0.0 env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} SLACK_TITLE: Slack Notification Demo SLACK_MESSAGE: Demo'ing the Slack Notification ``` -Go [here](deployment/git-actions/template_git_action_slack_notification.yml) for a template yml with all environment variables. +Go [here](deployment/github-actions/template_github_action_slack_notification.yml) for a template yml with all environment variables. 3\. Generate Slack WebHook [here](https://entelexeia.slack.com/apps/A0F7XDUAZ-incoming-webhooks?next_id=0) @@ -37,25 +37,25 @@ Go [here](deployment/git-actions/template_git_action_slack_notification.yml) for These are the environment variables that can be set to pass in additional information about the Git Action. -| Variable Name | Required | Description | -|--------------------|:--------:|-------------| -| GITHUB_ACTION | No | GitHub Action name variable passed from Git Actions | -| GITHUB_ACTOR | No | GitHub Actor variable passed from Git Actions | -| GITHUB_EVENT_NAME | No | GitHub Action event name variable passed from Git Actions | -| GITHUB_REF | No | GitHub reference variable passed from Git Actions | -| GITHUB_REPOSITORY | No | GitHub Repository variable passed from Git Actions | -| GITHUB_WORKFLOW | No | GitHub Action workflow varaible passed from Git Actions | -| SLACK_CHANNEL | No | The Slack channel to use instead of the default | -| SLACK_COLOR | No | Format color to use for the Slack message | -| SLACK_ICON | No | The Slack user icon to use instead of the default | -| SLACK_MESSAGE | Yes | The message payload to be sent to Slack| -| SLACK_TITLE | Yes | Title of the Slack message being sent. | -| SLACK_USERNAME | No | The Slack username to use instead of the default | -| SLACK_WEBHOOK | Yes | The Webhook URL generated by Slack to send messages too. | +| Variable Name | Required | Description | +| ----------------- | :------: | --------------------------------------------------------- | +| GITHUB_ACTION | No | GitHub Action name variable passed from Git Actions | +| GITHUB_ACTOR | No | GitHub Actor variable passed from Git Actions | +| GITHUB_EVENT_NAME | No | GitHub Action event name variable passed from Git Actions | +| GITHUB_REF | No | GitHub reference variable passed from Git Actions | +| GITHUB_REPOSITORY | No | GitHub Repository variable passed from Git Actions | +| GITHUB_WORKFLOW | No | GitHub Action workflow varaible passed from Git Actions | +| SLACK_CHANNEL | No | The Slack channel to use instead of the default | +| SLACK_COLOR | No | Format color to use for the Slack message | +| SLACK_ICON | No | The Slack user icon to use instead of the default | +| SLACK_MESSAGE | Yes | The message payload to be sent to Slack | +| SLACK_TITLE | Yes | Title of the Slack message being sent. | +| SLACK_USERNAME | No | The Slack username to use instead of the default | +| SLACK_WEBHOOK | Yes | The Webhook URL generated by Slack to send messages too. | ## Reference -* [Using environment variables](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables) lists the default environment variables set in Git Actions. +- [Using environment variables](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables) lists the default environment variables set in Git Actions. ## License diff --git a/action.yml b/action.yml index ba3e57a..9e89fb9 100644 --- a/action.yml +++ b/action.yml @@ -1,9 +1,9 @@ -name: 'Git Action Slack Notification' -description: 'Slack notification sent by Git Actions' -author: 'Senzing' +name: "GitHub Action Slack Notification" +description: "Slack notification sent by GitHub Actions" +author: "Senzing" branding: - icon: 'message-square' - color: 'purple' + icon: "message-square" + color: "purple" runs: - using: 'docker' - image: 'docker://senzing/git-action-slack-notification:1.0.0' + using: "docker" + image: "docker://senzing-factory/github-action-slack-notification:1.0.0" diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 8866222..2660240 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -15,11 +15,11 @@ RUN apk update && \ WORKDIR /go/src -RUN git clone https://github.com/senzing/git-action-slack-notification.git +RUN git clone https://github.com/senzing-factory/github-action-slack-notification.git # Checkout to target branch and if not master, then locally test # merging master into branch. -WORKDIR /go/src/git-action-slack-notification +WORKDIR /go/src/github-action-slack-notification RUN git checkout ${GITHUB_HEAD_REF}; \ if [[ "${GITHUB_HEAD_REF}" != "master" && ${GITHUB_EVENT_NAME} == "pull_request" ]]; then \ git merge master; \ @@ -35,15 +35,15 @@ FROM alpine:3.10 LABEL "com.github.actions.icon"="message-square" LABEL "com.github.actions.color"="purple" -LABEL "com.github.actions.name"="Git Aciton Slack Notification" +LABEL "com.github.actions.name"="GitHub Aciton Slack Notification" LABEL "com.github.actions.description"="Send notification to Slack" -COPY --from=BUILD /go/bin/git-action-slack-notification /usr/bin -COPY --from=BUILD /go/src/git-action-slack-notification/LICENSE / -COPY --from=BUILD /go/src/git-action-slack-notification/README.md / +COPY --from=BUILD /go/bin/github-action-slack-notification /usr/bin +COPY --from=BUILD /go/src/github-action-slack-notification/LICENSE / +COPY --from=BUILD /go/src/github-action-slack-notification/README.md / HEALTHCHECK CMD git --version || exit 1 USER 1001 -ENTRYPOINT ["git-action-slack-notification"] +ENTRYPOINT ["github-action-slack-notification"] diff --git a/deployment/git-actions/template_git_action_slack_notification.yml b/deployment/github-actions/template_github_action_slack_notification.yml similarity index 83% rename from deployment/git-actions/template_git_action_slack_notification.yml rename to deployment/github-actions/template_github_action_slack_notification.yml index e7529f8..7029cbf 100644 --- a/deployment/git-actions/template_git_action_slack_notification.yml +++ b/deployment/github-actions/template_github_action_slack_notification.yml @@ -1,5 +1,5 @@ on: push -name: Git Action Slack Notification Demo +name: GitHub Action Slack Notification Demo jobs: slackNotification: name: Slack Notification Demo @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@master - name: Slack Notification Demo - uses: senzing/git-action-slack-notification@1.0.0 + uses: senzing-factory/github-action-slack-notification@1.0.0 env: GITHUB_ACTION: ${GITHUB_ACTION} GITHUB_ACTOR: ${GITHUB_ACTOR} @@ -16,7 +16,7 @@ jobs: GITHUB_REPOSITORY: ${GITHUB_REPOSITORY} GITHUB_WORKFLOW: ${GITHUB_WORKFLOW} SLACK_CHANNEL: demo-channel - SLACK_COLOR: '#efefef' + SLACK_COLOR: "#efefef" SLACK_ICON: https://github.com/.png?size=48 SLACK_MESSAGE: Demo'ing the Slack Notification SLACK_TITLE: Slack Notification Demo diff --git a/go.mod b/go.mod index 14c1524..88623c3 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/senzing/git-action-slack-notification +module github.com/senzing-factory/github-action-slack-notification go 1.13 diff --git a/main.go b/main.go index c67fe2e..6824e2a 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "net/http" "github.com/pkg/errors" - "github.com/senzing/git-action-slack-notification/configuration" + "github.com/senzing-factory/github-action-slack-notification/configuration" ) type Message struct { From 3e9e3d1ce3e7a498384295a7f284ce6a388fab11 Mon Sep 17 00:00:00 2001 From: Sam <109683132+kernelsam@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:41:38 -0800 Subject: [PATCH 2/3] cleanup linting --- .github/linters/.yaml-lint.yml | 1 + CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 2 +- main.go | 3 ++- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml index 32ff17d..a72ba20 100644 --- a/.github/linters/.yaml-lint.yml +++ b/.github/linters/.yaml-lint.yml @@ -2,6 +2,7 @@ extends: default rules: + braces: { min-spaces-inside: 0, max-spaces-inside: 2 } comments-indentation: disable line-length: level: warning diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 2515417..deb0bd2 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@senzing.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at `support@senzing.com`. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 061a138..d16c895 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ There are a number of ways you can contribute: ## License Agreements -If your contribution modifies the git repository, the following agreements must be established. +If your contribution modifies the Git repository, the following agreements must be established. _Note:_ License agreements are only needed for adding, modifying, and deleting artifacts kept within the repository. In simple terms, license agreements are needed before pull requests can be accepted. diff --git a/main.go b/main.go index 6824e2a..82b1151 100644 --- a/main.go +++ b/main.go @@ -56,7 +56,8 @@ func (message *Message) Send(webhook string) error { } if response.StatusCode >= 299 { - err = fmt.Errorf(fmt.Sprintf("Exception: %s", response.Status)) + formatted := fmt.Sprintf("Exception: %s", response.Status) + err = fmt.Errorf("%s\n", formatted) } fmt.Println(response.Status) From 898b2d61845b118d567435b5160f8fa4f2d3efbd Mon Sep 17 00:00:00 2001 From: Sam <109683132+kernelsam@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:45:09 -0800 Subject: [PATCH 3/3] remove newline --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 82b1151..671f7b9 100644 --- a/main.go +++ b/main.go @@ -57,7 +57,7 @@ func (message *Message) Send(webhook string) error { if response.StatusCode >= 299 { formatted := fmt.Sprintf("Exception: %s", response.Status) - err = fmt.Errorf("%s\n", formatted) + err = fmt.Errorf("%s", formatted) } fmt.Println(response.Status)