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

Docker action #2

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions .github/workflows/actions-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on: [push]

jobs:
hello_world_job:
runs-on: [ubuntu-latest] # can't use self-hosted on action because it is public
name: A job to say hello
steps:

- name: Hello world action step
id: hello
uses: transferwise/[email protected]
with:
who-to-greet: 'Transferwise'
dir: /

# Use the output from the `hello` step
- name: Get all outputs
run: |
echo "The random id was ${{ steps.hello.outputs.random-id }}"
echo "The listing was: " && echo "${{ steps.hello.outputs.listing }}"
echo "The time was ${{ steps.hello.outputs.time }}"
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Container image that runs your code
FROM alpine:3.10
FROM docker-hub.tw.ee/alpine:3.10

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

COPY goodbye.sh /goodbye.sh
RUN chmod +x /goodbye.sh

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# actions-test
testing custom external github action
Example of a custom github action

## Usage example
```yml
steps:

- name: Hello world action step
id: hello
uses: transferwise/[email protected]
with:
who-to-greet: 'Transferwise'
dir: /

# Use the output from the `hello` step
- name: Get all outputs
run: |
echo "The random id was ${{ steps.hello.outputs.random-id }}"
echo "The listing was: " && echo "${{ steps.hello.outputs.listing }}"
echo "The time was ${{ steps.hello.outputs.time }}"
```

Run examples: https://github.com/transferwise/actions-test/pull/2/checks
54 changes: 13 additions & 41 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,31 @@
# action.yml
name: 'Hello World'
description: 'Greet someone and record the time'

inputs:
who-to-greet: # id of input
who-to-greet:
description: 'Who to greet'
required: true
default: 'World'
dir: # id of input
dir:
description: 'List of files'
required: true
default: './'

outputs:
time: # id of output
time:
description: 'The time we greeted you'
value: ${{ steps.time.outputs.time }}
random-id:
random-id:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-id }}
listing:
listing:
description: 'directory listing'
value: ${{ steps.listing.outputs.listing }}


runs:
# DOCKER ACTION
# using: 'docker'
# image: 'Dockerfile'
# args:
# - ${{ inputs.dir }}

# JS ACTION
# using: 'node12'
# main: 'index.js'

# COMPOSITE ACTION (bash)
using: "composite"
steps:
- run: echo Hello ${{ inputs.who-to-greet }}.
shell: bash
- id: listing
run: |
echo "Listing of directory ${{ inputs.dir }}"
LISTING=$(ls -la ${{ inputs.dir }})
echo $LISTING
echo "::set-output name=listing::'$(echo $LISTING)'"
shell: bash
- id: random-number-generator
run: echo "::set-output name=random-id::$(echo $RANDOM)"
shell: bash
- run: ${{ github.action_path }}/goodbye.sh ${{ inputs.who-to-greet }}
shell: bash
- id: time
run: |
TIME=$(date)
echo Time is: $TIME
echo "::set-output name=time::$(echo $TIME)"
shell: bash

using: 'docker'
image: './Dockerfile'
args:
- ${{ inputs.who-to-greet }}
- ${{ inputs.dir }}
post-entrypoint: '/goodbye.sh'
18 changes: 13 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#!/bin/sh -l

echo "Hello! Dir: $1"
echo "Hello ${1}!"


time=$(date)
echo "::set-output name=time::$time"
echo "Time is"
echo "${time}"
echo "time=$time" >> $GITHUB_OUTPUT

echo "Listing is "
ls -lah $2
LISTING=$(ls $2)
echo "listing=$LISTING" >> $GITHUB_OUTPUT

LISTING=$(ls -lah $1)
echo $LISTING
echo "::set-output name=listing::$LISTING"
echo "Set random"
echo "random-id=$RANDOM" >> $GITHUB_OUTPUT
1 change: 1 addition & 0 deletions goodbye.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh -l

echo "Good Bye!"
echo "(good bye ${1})"
27 changes: 0 additions & 27 deletions index.js

This file was deleted.

9 changes: 0 additions & 9 deletions node_modules/@actions/core/LICENSE.md

This file was deleted.

147 changes: 0 additions & 147 deletions node_modules/@actions/core/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions node_modules/@actions/core/lib/command.d.ts

This file was deleted.

Loading