From a98a930fa1ffec72878c7088ee66b88a228a9744 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sun, 9 May 2021 12:48:05 +0100 Subject: [PATCH] Add github action entrypoint. --- .github/workflows/release.yaml | 1 + Dockerfile | 2 +- action.yml | 7 ++++--- entrypoint.sh | 28 ++++++++++++++++++++++++++-- 4 files changed, 32 insertions(+), 6 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 42b266e..565608d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -175,6 +175,7 @@ jobs: - name: Create Release id: create_release uses: softprops/action-gh-release@v1 + if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/Dockerfile b/Dockerfile index a56aa1d..22f0b3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,5 +13,5 @@ RUN apk add --no-cache ca-certificates WORKDIR /go/src/app COPY --from=baseimg /go/src/app/semver-gen . COPY --from=baseimg /go/src/app/config-release.yaml config.yaml - +COPY entrypoint.sh entrypoint.sh CMD ["./semver-gen"] \ No newline at end of file diff --git a/action.yml b/action.yml index 873b58d..8cccc57 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,7 @@ runs: using: 'docker' image: 'Dockerfile' args: - - ${{ inputs.config-file }} - - ${{ inputs.repository-url }} - - ${{ inputs.repository-local }} \ No newline at end of file + - generate + - ${{ inputs.config_file }} + - ${{ inputs.repository_url }} + - ${{ inputs.repository_local }} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index 7ac1392..998c818 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,29 @@ #!/bin/sh -l +set -o pipefail -echo "Hello $1" +FLAGS="" -echo "::set-output name=semver::$time" \ No newline at end of file +if [[ -z "$INPUT_CONFIG_FILE" ]]; then + echo "Set the configuration file path." + exit 1 +else + FLAGS+=" -c $INPUT_CONFIG_FILE" +fi + +if [[ -z "$INPUT_REPOSITORY_URL" ]] && [[ -z "$INPUT_REPOSITORY_LOCAL" ]]; +then + echo "You need to set either remote repository or repository local flags." + exit 1 +fi + +if [[ ! -z "$INPUT_REPOSITORY_URL" ]]; then + FLAGS+=" -r $INPUT_REPOSITORY_URL" +fi + +if [[ ! -z "$INPUT_REPOSITORY_LOCAL" ]]; then + FLAGS+=" -l" +fi + +OUT_SEMVER_GEN=$(./semver-gen generate generate $FLAGS) +OUT_SEMVER=$(echo $OUT_SEMVER_GEN | sed -e 's|SEMVER ||g') +echo "::set-output name=semver::$OUT_SEMVER" \ No newline at end of file