diff --git a/README.md b/README.md index d2fb341..712f990 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,18 @@ Note: Since the action is not interactive, it invokes the CLI via `clojure` rath **Required**: The name of the datomic cloud stack. +### `uname` + +**Optional:** The [unreproducible name](https://docs.datomic.com/cloud/ions/ions-reference.html#unreproducible) for the push. + +### `maven-settings` + +**Optional:** The path to a custom maven settings.xml. Useful if you reference dependencies in a private maven repository. + +### `maven-repository` + +**Optional:** The path to your custom maven repository (eg "/github/workspace/.m2/repository"). Useful when used in combination with the [Cache Action](https://github.com/marketplace/actions/cache) in order to be able to specify a path to the maven repository visible outside this docker container. + ### `ssh-key` **Optional:** A GitHub secret that has the The SSH key needed to access code from other private repositories (eg `${{ secrets.SSH_PRIVATE_KEY }}`) @@ -158,7 +170,7 @@ Make sure that the AWS access keys you are providing to the action have an IAM p ### default, to run `:ion-dev` alias -```yaml +```yaml - name: Deploy Datomic ions uses: actions/datomic-ions-deploy@v0.1.0 with: @@ -172,7 +184,7 @@ Make sure that the AWS access keys you are providing to the action have an IAM p When you need to fetch private gitlibs with tools.deps, use `ssh-key` -```yaml +```yaml - name: Deploy Datomic ions uses: actions/datomic-ions-deploy@v0.1.0 with: @@ -186,7 +198,7 @@ When you need to fetch private gitlibs with tools.deps, use `ssh-key` ### with an alternative alias -```yaml +```yaml - name: Deploy Datomic ions uses: actions/datomic-ions-deploy@v0.1.0 with: @@ -200,13 +212,13 @@ When you need to fetch private gitlibs with tools.deps, use `ssh-key` ### with a different working directory -In case you want to use this action in a repository that has the ions code in a directory other than the root, -use the `working-dir` parameter. +In case you want to use this action in a repository that has the ions code in a directory other than the root, +use the `working-dir` parameter. Another use case might be that you have a github workflow that needs to run tests against a specific version of the ions code that is stored in another repository. -```yaml +```yaml - uses: actions/checkout@v2 # Checkout the ions code from another repository @@ -233,4 +245,3 @@ the ions code that is stored in another repository. # License The scripts and documentation in this project are released under the [MIT License](LICENSE) - diff --git a/action.yml b/action.yml index 4c91da4..e215a61 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,15 @@ inputs: app-name: description: "The datomic app name specified with the CloudFormation stack" required: true + uname: + description: "The uname for this deploy" + required: false + maven-settings: + description: "The path to maven settings.xml" + required: false + maven-repository: + description: "The path to maven repository" + required: false runs: using: 'docker' image: 'Dockerfile' @@ -43,3 +52,6 @@ runs: - ${{ inputs.working-directory }} - ${{ inputs.app-name }} - ${{ inputs.ssh-key }} + - ${{ inputs.uname }} + - ${{ inputs.maven-settings}} + - ${{ inputs.maven-repository}} diff --git a/entrypoint.sh b/entrypoint.sh index d5fd6b7..9d77aad 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,6 +21,21 @@ export AWS_SECRET_ACCESS_KEY=$5 WORKING_DIR=$6 APP_NAME=$7 SSH_KEY=$8 +UNAME=$9 +MAVEN_SETTINGS=${10} +MAVEN_REPOSITORY=${11} + +## Setup maven settings +if [[ -n $MAVEN_SETTINGS ]]; then + cp $MAVEN_SETTINGS $HOME/.m2/settings.xml +fi + +## Setup maven repository +if [[ -n $MAVEN_REPOSITORY ]]; then + rm -rf $HOME/.m2/repository + mkdir -p $MAVEN_REPOSITORY + mv $MAVEN_REPOSITORY $HOME/.m2/repository +fi ## Setup SSH Agent if [[ -n $SSH_KEY ]] @@ -55,7 +70,12 @@ function get_version { function push { # Push the ions code to AWS - clojure $a_Opts "{:op :push :region $AWS_REGION}" + + if [[ -n $UNAME ]]; then + clojure $a_Opts "{:op :push :region $AWS_REGION :uname $UNAME}" + else + clojure $a_Opts "{:op :push :region $AWS_REGION}" + fi } function getDeployStatus() { @@ -92,7 +112,11 @@ function deploy { ## if this fails, print out the error instead of sending it to the file set +e - CLJ_OUTPUT=$(clojure -Sforce -A:ion-dev "{:op :deploy, :region $AWS_REGION, :group $1, :rev \"$SHA\"}") + if [[ -n $UNAME ]]; then + CLJ_OUTPUT=$(clojure -Sforce -A:ion-dev "{:op :deploy, :region $AWS_REGION, :group $1, :uname \"$UNAME\"}") + else + CLJ_OUTPUT=$(clojure -Sforce -A:ion-dev "{:op :deploy, :region $AWS_REGION, :group $1, :rev \"$SHA\"}") + fi if [ $? -eq 0 ]; then echo $CLJ_OUTPUT >.deploys/$1_$SHA @@ -106,7 +130,17 @@ function deploy { waitUntilDeployed "$1_$SHA" } +function prepare-maven-cache { + + if [[ -n $MAVEN_REPOSITORY ]]; then + rm -rf $MAVEN_REPOSITORY + mv $HOME/.m2/repository $MAVEN_REPOSITORY + fi + +} + if [[ $SHA != $(get_version $COMPUTE_GROUP $APP_NAME) ]]; then push deploy $COMPUTE_GROUP + prepare-maven-cache fi