Skip to content

Commit

Permalink
First attempt to add gh-action (#5)
Browse files Browse the repository at this point in the history
* first attempt to add gh-action
* adding entrypoint.sh
* need to install bash'

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Co-authored-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch and vsoch committed Aug 29, 2021
1 parent c17248d commit dc5f879
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI
on: [pull_request]

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2
- name: Test dockerfile uptodate GitHub Action
uses: ./
with:
root: ./tests
parser: dockerfile

- name: Check output files
run: |
sudo apt-get install -y tree
tree ./tests
- name: Test dockerhierarchy uptodate GitHub Action
uses: ./
with:
root: ./tests
parser: dockerhierarchy

- name: Check output files again
run: |
tree ./tests
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM golang:alpine as builder

ARG version
LABEL maintainer="@vsoch"

LABEL "com.github.actions.name"="UpToDate Action"
LABEL "com.github.actions.description"="Check that repository assets are up to date"
LABEL "com.github.actions.icon"="activity"
LABEL "com.github.actions.color"="blue"

# Install module dependencies
WORKDIR /code
COPY go.mod go.sum ./
RUN go mod download

# Copy the rest!
COPY . .

# Install some dependencies
RUN apk add --no-cache binutils build-base linux-headers

# Build the action
RUN make

# Multistage build to only copy over the binary
FROM alpine

RUN apk add --no-cache git bash
WORKDIR /code
COPY --from=builder /code/uptodate /code/entrypoint.sh /code/
ENV PATH /code:$PATH
ENTRYPOINT ["/bin/bash", "/code/entrypoint.sh"]
26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "uptodate-action"
author: "Vanessa Sochat"
description: "Check that repository assets are up to date"

inputs:
root:
description: "Root path to provide to command. Can be a Dockerfile or directory."
required: false
default: ""

parser:
description: "Parser to run, one of dockerfile, or dockerhierarchy"
required: true

dry_run:
description: "Do a dry run (don't write, but show changes) one of true or false, defaults to false"
required: false
default: false

runs:
using: "docker"
image: "Dockerfile"

branding:
icon: "activity"
color: "blue"
22 changes: 22 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

printf "Found files in workspace:\n"
ls

printf "Looking for uptodate install...\n"
which uptodate

COMMAND="uptodate ${INPUT_PARSER} "

# dry run?
if [ "${INPUT_DRY_RUN}" == "true" ]; then
COMMAND="${COMMAND} --dry-run"
fi

COMMAND="${COMMAND} ${INPUT_ROOT}"
echo "${COMMAND}"

${COMMAND}
echo $?
5 changes: 5 additions & 0 deletions tests/ubuntu/21.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:21.04

LABEL maintainer vsoch

RUN apt-get update && apt-get install -y vim
12 changes: 12 additions & 0 deletions tests/ubuntu/uptodate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dockerhierarchy:
container:
name: ubuntu
filter:
# we only want XX.04 versions
- "^[0-9]+[.]04$"
startat: "16.04"

# Versions to skip (not LTS releases)
skips:
- "17.04"
- "19.04"

0 comments on commit dc5f879

Please sign in to comment.