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

Add a Hello World action #4

Merged
merged 6 commits into from
Nov 26, 2021
Merged
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
6 changes: 6 additions & 0 deletions .github/actions/hello-world/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/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "my hello action"

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/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)
}

}
9 changes: 5 additions & 4 deletions .github/workflows/my-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Docker Actions
name: "Docker Actions"

on: [push]

jobs:
action:
runs-on: ubuntu-latest

runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v1

- name: hello-action
- name: "hello-action"
uses: ./.github/actions/hello-world
with:
firstGreeting: "Learning Lab User"