Skip to content

Commit 3da5e53

Browse files
committed
Initial commit
0 parents  commit 3da5e53

File tree

12 files changed

+665
-0
lines changed

12 files changed

+665
-0
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# local-action
2+
3+
<!-- about this action -->
4+
5+
| Input | Description | Required |
6+
| ------- | ----------------------------------------------------------------------------------------------------------- | -------- |
7+
| `token` | Token used to access the GitHub API. Use the `GITHUB_TOKEN` by default unless other permissions are needed. | yes |
8+
9+
## What checks does this action conduct?
10+
11+
- some
12+
- list
13+
- of
14+
- checks
15+
16+
## What about this action is sensitive or might raise security concerns?
17+
18+
## Summary
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "local-action"
2+
description: Grading action for local exercise
3+
author: githubtraining
4+
inputs:
5+
token:
6+
description: GITHUB_TOKEN used to access the API
7+
required: true
8+
9+
runs:
10+
using: node12
11+
main: "dist/index.js"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const github = require("@actions/github");
2+
const core = require("@actions/core");
3+
4+
module.exports = async () => {
5+
const token = core.getInput("token");
6+
const octokit = github.getOctokit(token);
7+
8+
try {
9+
// Do some logic to verify the leaner understands
10+
11+
if (GOOD - RESULT) {
12+
return {
13+
reports: [
14+
{
15+
filename: "",
16+
isCorrect: true,
17+
display_type: "actions",
18+
level: "info",
19+
msg: "Great job!",
20+
error: {
21+
expected: "",
22+
got: "",
23+
},
24+
},
25+
],
26+
};
27+
// BAD-RESULT
28+
} else {
29+
return {
30+
reports: [
31+
{
32+
filename: "",
33+
isCorrect: false,
34+
display_type: "actions",
35+
level: "warning",
36+
msg: `incorrect solution`,
37+
error: {
38+
expected: "What we expecrted",
39+
got: `What we got`,
40+
},
41+
},
42+
],
43+
};
44+
}
45+
} catch (error) {
46+
return {
47+
reports: [
48+
{
49+
filename: filename,
50+
isCorrect: false,
51+
display_type: "actions",
52+
level: "fatal",
53+
msg: "",
54+
error: {
55+
expected: "",
56+
got: "An internal error occurred. Please open an issue at: https://github.com/githubtraining/exercise-remove-commit-history and let us know! Thank you",
57+
},
58+
},
59+
],
60+
};
61+
}
62+
};

.github/actions/local-action/main.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const core = require("@actions/core");
2+
3+
const gradeLearner = require("./lib/gradeLearner");
4+
5+
async function run() {
6+
try {
7+
const results = await gradeLearner();
8+
core.setOutput("reports", results);
9+
} catch (error) {
10+
core.setFailed(error);
11+
}
12+
}
13+
14+
run();
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "local-action",
3+
"version": "1.0.0",
4+
"description": "Local exercise action to verify the desire commit was removed",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "ncc build main.js"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/githubtraining/exercise-enable-code-scanning-using-codeql.git"
13+
},
14+
"author": "githubtraining",
15+
"license": "MIT",
16+
"bugs": {
17+
"url": "https://github.com/githubtraining/exercise-enable-code-scanning-using-codeql/issues"
18+
},
19+
"homepage": "https://github.com/githubtraining/exercise-enable-code-scanning-using-codeql#readme",
20+
"dependencies": {
21+
"@actions/core": "^1.4.0",
22+
"@actions/github": "^5.0.0"
23+
}
24+
}

.github/workflows/CI.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI for local local-action
2+
on:
3+
push:
4+
branches-ignore:
5+
- main
6+
7+
jobs:
8+
run-tests:
9+
if: github.repository == 'githubtraining/exercise-enable-code-scanning-using-codeql'
10+
runs-on: ubuntu-latest
11+
defaults:
12+
run:
13+
working-directory: .github/actions/local-action
14+
steps:
15+
- name: checkout repo
16+
uses: actions/checkout@v2
17+
18+
- name: install dependencies
19+
run: npm ci
20+
21+
- name: run tests
22+
run: npm run test

.github/workflows/grading.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Grading workflow
2+
on: push
3+
4+
jobs:
5+
grade-learner:
6+
if: github.event_name == 'push' # Apply additional filters as needed
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
11+
- name: Grade exercise-enable-code-scanning-using-codeql activity
12+
id: events
13+
uses: ./.github/actions/local-action
14+
with:
15+
github-token: ${{secrets.GITHUB_TOKEN}}
16+
17+
- name: Grading results
18+
uses: githubtraining/[email protected]
19+
with:
20+
github-token: ${{secrets.GITHUB_TOKEN}}
21+
feedback: ${{ steps.events.outputs.reports }}
22+
troubleshoot-activity:
23+
if: github.event_name == 'workflow_dispatch'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: troubleshooting steps
27+
run: echo "" #Help the user to troubleshoot the activity

.github/workflows/link-checker.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Check Markdown links
2+
3+
on: push
4+
5+
jobs:
6+
markdown-link-check:
7+
runs-on: ubuntu-latest
8+
if: github.repository == 'githubtraining/exercise-enable-code-scanning-using-codeql'
9+
steps:
10+
- uses: actions/checkout@master
11+
- uses: gaurav-nelson/github-action-markdown-link-check@v1

.github/workflows/setup.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Initial repo configuration
2+
#on: push
3+
4+
jobs:
5+
setup-repo:
6+
runs-on: ubuntu-latest
7+
if: github.event.commits[0].message == 'Initial commit' && github.repository != 'githubtraining/exercise-enable-code-scanning-using-codeql'
8+
steps:
9+
# - name: Checkout repo
10+
# uses: actions/checkout@v2
11+
12+
# - name: Configure exercise
13+
# uses: githubtraining/stage-commits-action@main

0 commit comments

Comments
 (0)