mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-08-23 22:26:29 +00:00
Add golang tools GitHub Action
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
FROM golang:1.10
|
||||
|
||||
LABEL "name"="golang tools action"
|
||||
LABEL "maintainer"="Stefan Prodan <support@gweave.works>"
|
||||
LABEL "version"="1.0.0"
|
||||
|
||||
LABEL "com.github.actions.icon"="code"
|
||||
LABEL "com.github.actions.color"="gray-dark"
|
||||
LABEL "com.github.actions.name"="Go Tools"
|
||||
LABEL "com.github.actions.description"="This is an Action to run go and dep commands."
|
||||
|
||||
ENV DEP_VERSION="v0.5.0"
|
||||
|
||||
RUN curl -fL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/${DEP_VERSION}/dep-linux-amd64 \
|
||||
&& chmod +x /usr/local/bin/dep
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
set -e
|
||||
|
||||
APP_DIR="/go/src/github.com/${GITHUB_REPOSITORY}/"
|
||||
|
||||
mkdir -p ${APP_DIR} && cp -r ./ ${APP_DIR} && cd ${APP_DIR}
|
||||
|
||||
if [[ "$1" == "fmt" ]]; then
|
||||
echo "Running gofmt"
|
||||
files=$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*") 2>&1)
|
||||
if [ "$files" ]; then
|
||||
echo "These files did not pass the gofmt check:"
|
||||
echo ${files}
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$1" == "test" ]]; then
|
||||
echo "Running go test"
|
||||
go test $(go list ./... | grep -v /vendor/) -cover
|
||||
fi
|
||||
|
||||
+14
-2
@@ -3,13 +3,25 @@ workflow "Publish container" {
|
||||
resolves = ["Docker tag and push"]
|
||||
}
|
||||
|
||||
action "Test and build" {
|
||||
action "Lint" {
|
||||
uses = "./.github/actions/golang"
|
||||
args = "fmt"
|
||||
}
|
||||
|
||||
action "Test" {
|
||||
needs = ["Lint"]
|
||||
uses = "./.github/actions/golang"
|
||||
args = "test"
|
||||
}
|
||||
|
||||
action "Build" {
|
||||
needs = ["Test"]
|
||||
uses = "actions/docker/cli@master"
|
||||
args = "build -t app -f Dockerfile.ci ."
|
||||
}
|
||||
|
||||
action "Docker login" {
|
||||
needs = ["Test and build"]
|
||||
needs = ["Build"]
|
||||
uses = "actions/docker/login@master"
|
||||
secrets = ["DOCKER_USERNAME", "DOCKER_PASSWORD"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user