Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CalinL authored Feb 6, 2023
0 parents commit 883d3d1
Show file tree
Hide file tree
Showing 61 changed files with 53,575 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/actions/cat-facts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3

COPY requirements.txt ./

RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "/src/main.py" ]
11 changes: 11 additions & 0 deletions .github/actions/cat-facts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "my cat fact action"

description: "Get external data with GitHub Actions"

outputs:
fact:
description: Resulting cat fact from the https://cat-fact.herokuapp.com/facts api

runs:
using: "docker"
image: "Dockerfile"
1 change: 1 addition & 0 deletions .github/actions/cat-facts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
29 changes: 29 additions & 0 deletions .github/actions/cat-facts/src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import requests
import random
import sys

# Make an HTTP GET request to the cat-fact API
cat_url = "https://cat-fact.herokuapp.com/facts"
r = requests.get(cat_url)
r_obj_list = r.json()

# Create an empty list to store individual facts in
# This will make it easy to select a random one later
fact_list = []

# Add the "text" of every object into the fact_list list
for fact in r_obj_list:
fact_list.append(fact["text"])

# Select a random fact from the fact_list and return it
# into a variable named random_fact so we can use it
def select_random_fact(fact_arr):
return fact_arr[random.randint(0, len(fact_list)+1)]

random_fact = select_random_fact(fact_list)

# Print the individual randomly returned cat-fact
print(random_fact)

# Set the fact-output of the action as the value of random_fact
print(f"::set-output name=fact::{random_fact}")
21 changes: 21 additions & 0 deletions .github/actions/hello-world-composite-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Hello World Composite Action'
description: 'Greet someone'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-id }}
runs:
using: "composite"
steps:
- run: echo Hello from composite action ${{ inputs.who-to-greet }}.
shell: bash
- id: random-number-generator
run: echo "::set-output name=random-id::$(echo $RANDOM)"
shell: bash
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
6 changes: 6 additions & 0 deletions .github/actions/hello-world-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM golang:1.15
WORKDIR /go/src/hello
COPY . .
RUN go get -d -v ./...
RUN go install -v ./...
CMD ["hello"]
22 changes: 22 additions & 0 deletions .github/actions/hello-world-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "my hello action docker"

description: "say hello with GitHub Actions"

inputs:
firstGreeting:
description: "who would you like to greet in the console"
required: true
default: "Hubot"

secondGreeting:
description: "another person to greet"
required: true
default: "Mona the Octocat"

thirdGreeting:
description: "a third greeting"
required: false

runs:
using: "docker"
image: "Dockerfile"
24 changes: 24 additions & 0 deletions .github/actions/hello-world-docker/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"fmt"
"os"
)

func main() {

// Access Inputs as environment vars
firstGreeting := os.Getenv("INPUT_FIRSTGREETING")
secondGreeting := os.Getenv("INPUT_SECONDGREETING")
thirdGreeting := os.Getenv("INPUT_THIRDGREETING")

// Use those inputs in the actions logic
fmt.Println("Hello " + firstGreeting)
fmt.Println("Hello " + secondGreeting)

// Someimes inputs are not "required" and we can build around that
if thirdGreeting != "" {
fmt.Println("Hello " + thirdGreeting)
}

}
7 changes: 7 additions & 0 deletions .github/actions/hello-world-js/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "my hello action JS"

description: "say hello with GitHub Actions"

runs:
using: "node12"
main: "dist/index.js"
59 changes: 59 additions & 0 deletions .github/actions/hello-world-js/dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module.exports =
/******/ (function(modules, runtime) { // webpackBootstrap
/******/ "use strict";
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ __webpack_require__.ab = __dirname + "/";
/******/
/******/ // the startup function
/******/ function startup() {
/******/ // Load entry module and return exports
/******/ return __webpack_require__(104);
/******/ };
/******/
/******/ // run startup
/******/ return startup();
/******/ })
/************************************************************************/
/******/ ({

/***/ 104:
/***/ (function() {

console.log("Hello World");

/***/ })

/******/ });
1 change: 1 addition & 0 deletions .github/actions/hello-world-js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Hello World");
78 changes: 78 additions & 0 deletions .github/actions/hello-world-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .github/actions/hello-world-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "hello-world",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.6.0"
}
}
9 changes: 9 additions & 0 deletions .github/actions/issue-maker-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:slim

COPY package*.json ./

RUN npm install

COPY . .

CMD [ "node", "/src/index.js" ]
22 changes: 22 additions & 0 deletions .github/actions/issue-maker-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "issue maker"

description: "create and issue with a cat fact as the body"

inputs:
issueTitle:
description: "A name for the cat-fact issue"
required: true
default: "A cat fact for you"

catFact:
description: "the cat fact retreived from a previous action"
required: true
default: "Mona is an Octocat"

repoToken:
description: "Authentication token, use secrets.GITHUB_TOKEN"
required: true

runs:
using: "docker"
image: "Dockerfile"
16 changes: 16 additions & 0 deletions .github/actions/issue-maker-docker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "issue-maker",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.2.2",
"@actions/github": "^2.1.0"
}
}
23 changes: 23 additions & 0 deletions .github/actions/issue-maker-docker/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const core = require("@actions/core");
const github = require("@actions/github");

async function run() {
const issueTitle = core.getInput("issueTitle");
const catFact = core.getInput("catFact");

const token = core.getInput("repoToken");
try {
const octokit = new github.GitHub(token);

const newIssue = await octokit.issues.create({
repo: github.context.repo.repo,
owner: github.context.repo.owner,
title: issueTitle,
body: catFact
});
} catch (error) {
core.setFailed(error.message);
}
}

run();
17 changes: 17 additions & 0 deletions .github/actions/issue-maker-js/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "I have issues"

description: "consume the output of the previous action and create a new issue in the repository"

inputs:
joke:
description: "This will become the body of the created issue"
issue-title:
description: "Every issue needs a title, it's nice to supply one, even though you could do this dynamically within your code"
default: "a joke for you"
required: true
repo-token:
description: "Token with permissions to do repo things"

runs:
using: "node12"
main: "dist/index.js"
Loading

0 comments on commit 883d3d1

Please sign in to comment.