Skip to content

Commit

Permalink
Merge pull request #4 from Jtalk/working-dir-support-test
Browse files Browse the repository at this point in the history
Support for the working-directory input + action check
  • Loading branch information
matankdr authored May 5, 2020
2 parents f48f52b + c429231 commit cbbd7cd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/data/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name := "test-project"
version := "1.0"
scalaVersion := "2.12.11"

lazy val userdir = taskKey[Unit]("Print user.dir proprety")
userdir := { // sbt userdir is going to crash if not in this directory
println(System.getProperty("user.dir"))
}
22 changes: 22 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check action

on: [push]

jobs:
check-baseline:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Verify sbt command gets invoked in the specified directory
uses: ./
with:
command: sbt name
check-working-dir:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Verify sbt command gets invoked in the specified directory
uses: ./
with:
command: sbt userdir
working-directory: .github/data
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ project/boot/
project/plugins/project/
.history

# action test specific
.github/target

# Scala-IDE specific
.scala_dependencies
.classpath
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ name: Run test and upload container
uses: matankdr/[email protected]
with:
command: sbt test docker:publish publish
working-directory: subproject/
packages-resolver: "ivy creds"
docker-login-username: "my username"
docker-login-password: "my password"
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
command: # id of input
description: 'Commands to run'
required: true
working-directory:
description: 'A directory to run SBT in'
required: false
default: .
docker-login-username: # Docker login username
description: 'docker login username'
required: false
Expand All @@ -24,6 +28,7 @@ runs:
- ${{ inputs.docker-login-username }}
- ${{ inputs.docker-login-password }}
- ${{ inputs.docker-registry }}
- ${{ inputs.working-directory }}

branding:
icon: 'package'
Expand Down
7 changes: 5 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ git config --global user.name ${GITHUB_USERNAME}
git config --global user.password ${GITHUB_PASSWORD}

COMMAND=$1
if [[ -z "${2}" || -z "${3}" ]]; then
WORKING_DIR="$5"

if [[ -z "${2}" || -z "${3}" || -z "${4}" ]]; then
echo "One or more variables are not defined, will only run command"
else
DOCKER_USERNAME=$2
Expand All @@ -17,5 +19,6 @@ else
echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin ${DOCKER_REGISTRY}
fi

echo "Running command"
echo "Running command in ${WORKING_DIR}"
cd "$WORKING_DIR" || { echo "Cannot change into directory ${WORKING_DIR}"; exit 1; }
${COMMAND}

0 comments on commit cbbd7cd

Please sign in to comment.