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

fix: evaluated GitHub actions workflow files #268

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 16 additions & 9 deletions .github/workflows/notify-tsc-members-mention.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ jobs:
CALENDAR_ID: ${{ secrets.CALENDAR_ID }}
CALENDAR_SERVICE_ACCOUNT: ${{ secrets.CALENDAR_SERVICE_ACCOUNT }}
MAILCHIMP_API_KEY: ${{ secrets.MAILCHIMP_API_KEY }}
ISSUE_TITLE: ${{ github.event.issue.title }}
with:
script: |
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
mhmohona marked this conversation as resolved.
Show resolved Hide resolved
sendEmail('${{github.event.issue.html_url}}', '${{github.event.issue.title}}');
sendEmail('${{github.event.issue.html_url}}', process.env.ISSUE_TITLE);

pull_request:
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.body, '@asyncapi/tsc_members')
Expand Down Expand Up @@ -111,10 +112,12 @@ jobs:
CALENDAR_ID: ${{ secrets.CALENDAR_ID }}
CALENDAR_SERVICE_ACCOUNT: ${{ secrets.CALENDAR_SERVICE_ACCOUNT }}
MAILCHIMP_API_KEY: ${{ secrets.MAILCHIMP_API_KEY }}
PR_TITLE: ${{ github.event.pull_request.title }}

with:
script: |
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
sendEmail('${{github.event.pull_request.html_url}}', '${{github.event.pull_request.title}}');
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
sendEmail('${{github.event.pull_request.html_url}}', process.env.PR_TITLE);

discussion:
if: github.event_name == 'discussion' && contains(github.event.discussion.body, '@asyncapi/tsc_members')
Expand Down Expand Up @@ -156,10 +159,11 @@ jobs:
CALENDAR_ID: ${{ secrets.CALENDAR_ID }}
CALENDAR_SERVICE_ACCOUNT: ${{ secrets.CALENDAR_SERVICE_ACCOUNT }}
MAILCHIMP_API_KEY: ${{ secrets.MAILCHIMP_API_KEY }}
DISCUSSION_TITLE: ${{ github.event.discussion.title }}
with:
script: |
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
sendEmail('${{github.event.discussion.html_url}}', '${{github.event.discussion.title}}');
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
sendEmail('${{github.event.discussion.html_url}}', process.env.DISCUSSION_TITLE);

issue_comment:
if: ${{ github.event_name == 'issue_comment' && !github.event.issue.pull_request && contains(github.event.comment.body, '@asyncapi/tsc_members') }}
Expand Down Expand Up @@ -201,10 +205,11 @@ jobs:
CALENDAR_ID: ${{ secrets.CALENDAR_ID }}
CALENDAR_SERVICE_ACCOUNT: ${{ secrets.CALENDAR_SERVICE_ACCOUNT }}
MAILCHIMP_API_KEY: ${{ secrets.MAILCHIMP_API_KEY }}
ISSUE_TITLE: ${{ github.event.issue.title }}
with:
script: |
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
sendEmail('${{github.event.comment.html_url}}', '${{github.event.issue.title}}');
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
sendEmail('${{github.event.comment.html_url}}', process.env.ISSUE_TITLE);

pr_comment:
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@asyncapi/tsc_members')
Expand Down Expand Up @@ -246,10 +251,11 @@ jobs:
CALENDAR_ID: ${{ secrets.CALENDAR_ID }}
CALENDAR_SERVICE_ACCOUNT: ${{ secrets.CALENDAR_SERVICE_ACCOUNT }}
MAILCHIMP_API_KEY: ${{ secrets.MAILCHIMP_API_KEY }}
PR_TITLE: ${{ github.event.issue.title }}
with:
script: |
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
sendEmail('${{github.event.comment.html_url}}', '${{github.event.issue.title}}');
sendEmail('${{github.event.comment.html_url}}', process.env.PR_TITLE);

discussion_comment:
if: github.event_name == 'discussion_comment' && contains(github.event.comment.body, '@asyncapi/tsc_members')
Expand Down Expand Up @@ -291,7 +297,8 @@ jobs:
CALENDAR_ID: ${{ secrets.CALENDAR_ID }}
CALENDAR_SERVICE_ACCOUNT: ${{ secrets.CALENDAR_SERVICE_ACCOUNT }}
MAILCHIMP_API_KEY: ${{ secrets.MAILCHIMP_API_KEY }}
DISCUSSION_TITLE: ${{ github.event.discussion.title }}
with:
script: |
const sendEmail = require('./.github/workflows/scripts/mailchimp/index.js');
sendEmail('${{github.event.comment.html_url}}', '${{github.event.discussion.title}}');
sendEmail('${{github.event.comment.html_url}}', process.env.DISCUSSION_TITLE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you modify it because the linter complained?

I wonder then why github.event.comment.html_url did not have to be refactored as well 🤔

58 changes: 2 additions & 56 deletions .github/workflows/validate-workflow-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,5 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: actions/checkout@v2
uses: actions/checkout@v4


- name: Install Dependencies
run: npm install yaml-lint ajv axios js-yaml

- name: Lint YAML Files
run: |
set -e
find .github/workflows -type f -name "*.yml" -print0 | xargs -0 ./node_modules/.bin/yamllint -q

- name: List YAML files to validate
run: |
set -e
files=$(find .github/workflows -name '*.yml')
echo "Validating the following files:"
echo "$files"

- name: Run YAML validation
uses: actions/github-script@v6
with:
script: |
const Ajv = require("ajv");
const axios = require("axios");
const yaml = require("js-yaml");
const fs = require("fs").promises;

async function validateWorkflows() {
const schema = await axios.get(
"https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json"
);

const files = await fs.readdir(".github/workflows");
const ymlFiles = files.filter((file) => file.endsWith(".yml"));

for (const file of ymlFiles) {
try {
const content = await fs.readFile(`.github/workflows/${file}`, "utf8");
const target = yaml.load(content);

const ajv = new Ajv({ strict: false, allErrors: true });
const validator = ajv.compile(schema.data);
const valid = validator(target);
if (!valid) {
console.error(
`Validation failed for file '${file}' with the following errors:`
);
console.error(validator.errors);
process.exitCode = 1;
} else {
console.log(`Workflow in file '${file}' is valid`);
}
} catch (error) {
console.error(`Error validating file '${file}': ${error.message}`);
process.exitCode = 1;
}
}
}
validateWorkflows();
- name: Check workflow files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not use directly v1 when action is not official, from github, but commit id (in your other PR you do it, so you have example there)

uses: raven-actions/actionlint@v1
Loading