diff --git a/Dockerfile b/Dockerfile index 25512e5..fad1908 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM mongo:latest WORKDIR /action COPY entrypoint.sh . +COPY cleanup.sh . RUN chmod +x entrypoint.sh +RUN chmod +x cleanup.sh ENTRYPOINT ["/action/entrypoint.sh"] diff --git a/action.yml b/action.yml index 3ac9a78..df8ebce 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,7 @@ runs: args: - ${{ inputs.connection-string }} - ${{ inputs.compress }} + post-entrypoint: '/action/cleanup.sh' branding: icon: 'database' diff --git a/cleanup.sh b/cleanup.sh new file mode 100644 index 0000000..1d1094a --- /dev/null +++ b/cleanup.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +rm -rf $GITHUB_WORKSPACE/dump +if [ $? -eq 0 ]; then + echo "Dump removed" +fi + +if [ "$2" = "true" ]; then + rm $GITHUB_WORKSPACE/dump.tar.gz + if [ $? -eq 0 ]; then + echo "Compressed dump removed" + fi +fi diff --git a/entrypoint.sh b/entrypoint.sh index b559cb5..fb2fe6f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,9 @@ #!/bin/bash cd /action -mongodump $1 +mongodump --uri=$1 mkdir $GITHUB_WORKSPACE/dump -cp -r dump $GITHUB_WORKSPACE/dump +mv dump $GITHUB_WORKSPACE/ echo "Dump created and stored in $GITHUB_WORKSPACE/dump"