diff --git a/cli/Dockerfile b/cli/Dockerfile index 8c6b523..8d7558e 100644 --- a/cli/Dockerfile +++ b/cli/Dockerfile @@ -12,4 +12,5 @@ LABEL "com.github.actions.color"="blue" RUN npm install -g netlify-cli COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["sh", "/entrypoint.sh"] diff --git a/cli/README.md b/cli/README.md index ee95e7e..c256dc2 100644 --- a/cli/README.md +++ b/cli/README.md @@ -11,11 +11,13 @@ This Action enables arbitrary actions with the [Netlify CLI](https://github.com/ ## Outputs The following outputs will be available from a step that uses this action: -- `NETLIFY_OUTPUT`, the full stdout from the run of the `netlify` command - `NETLIFY_URL`, the URL of the draft site that Netlify provides - `NETLIFY_LOGS_URL`, the URL where the logs from the deploy can be found - `NETLIFY_LIVE_URL`, the URL of the "real" site, set only if `--prod` was passed +> The full stdout from the run of the `netlify` command is printed in the GitHub Actions workflow logs. + + See [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions) for info and examples of how to use outputs in later steps and jobs. ## Example @@ -33,7 +35,7 @@ jobs: - name: Publish uses: netlify/actions/cli@master with: - args: deploy --dir=site --functions=functions + args: deploy --prod --dir=./build --message="Deploy from Github Action" env: NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} diff --git a/cli/entrypoint.sh b/cli/entrypoint.sh index 890fbe3..f3dc6aa 100755 --- a/cli/entrypoint.sh +++ b/cli/entrypoint.sh @@ -4,18 +4,20 @@ read -d '' COMMAND <<- EOF if [ -f "$HOME/ignore" ] && grep "^ignore:$BUILD_DIR" "$HOME/ignore"; then echo "$BUILD_DIR didn't change" else - ${BUILD_COMMAND:-echo} && netlify $* + ${BUILD_COMMAND:-echo} && netlify $@ fi EOF +echo "running ${COMMAND}" OUTPUT=$(sh -c "$COMMAND") +echo "$OUTPUT" -NETLIFY_OUTPUT=$(echo "$OUTPUT") -NETLIFY_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*(--)[a-zA-Z0-9./?=_-]*') #Unique key: -- -NETLIFY_LOGS_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://app.netlify.com/[a-zA-Z0-9./?=_-]*') #Unique key: app.netlify.com -NETLIFY_LIVE_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*' | grep -Eov "netlify.com") #Unique key: don't containr -- and app.netlify.com +NETLIFY_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*(--)[a-zA-Z0-9./?=_-]*' | head -n 1) +NETLIFY_LOGS_URL=$(echo "$OUTPUT" | grep "Build logs:" | grep -Eo '(http|https)://app.netlify.com/[a-zA-Z0-9./?=_-]*' | head -n 1) +NETLIFY_LIVE_URL=$(echo "$OUTPUT" | grep -i "production URL:" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*' | head -n 1) -echo "::set-output name=NETLIFY_OUTPUT::$NETLIFY_OUTPUT" -echo "::set-output name=NETLIFY_URL::$NETLIFY_URL" -echo "::set-output name=NETLIFY_LOGS_URL::$NETLIFY_LOGS_URL" -echo "::set-output name=NETLIFY_LIVE_URL::$NETLIFY_LIVE_URL" +{ + echo "NETLIFY_URL=$NETLIFY_URL" + echo "NETLIFY_LOGS_URL=$NETLIFY_LOGS_URL" + echo "NETLIFY_LIVE_URL=$NETLIFY_LIVE_URL" +} >> "$GITHUB_OUTPUT"