Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use different environment variable for instance setup #6

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
force-push:
description: 'Force push to Platform.sh'
required: false
environment-name:
description: 'Name of the platform.sh instance'
required: false
runs:
using: "composite"
steps:
Expand All @@ -29,13 +32,22 @@ runs:
- uses: adam7/[email protected]
with:
token: ${{ inputs.cli-token }}
-
name: Set environment name
id: set_environment_name
shell: bash
run: |
ENVIRONMENT_NAME=${{ inputs.environment-name }}
[[ "$ENVIRONMENT_NAME" == "" ]] && ENVIRONMENT_NAME="$GITHUB_REF_NAME"
echo "::set-output name=url::$ENVIRONMENT_NAME"
Comment on lines +35 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very fond of this. I think we can handle this in the shell script itself quite robustly. See my other two suggestions.

Comment on lines +35 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-
name: Set environment name
id: set_environment_name
shell: bash
run: |
ENVIRONMENT_NAME=${{ inputs.environment-name }}
[[ "$ENVIRONMENT_NAME" == "" ]] && ENVIRONMENT_NAME="$GITHUB_REF_NAME"
echo "::set-output name=url::$ENVIRONMENT_NAME"

- run: ${{ github.action_path }}/deploy.sh
shell: bash
env:
SSH_PRIVATE_KEY: ${{ inputs.ssh-private-key }}
PLATFORM_PROJECT_ID: ${{ inputs.project-id }}
PLATFORMSH_CLI_TOKEN: ${{ inputs.cli-token }}
FORCE_PUSH: ${{ inputs.force-push }}
ENVIRONMENT_NAME: ${{ steps.set_environment_name.outputs.url }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ENVIRONMENT_NAME: ${{ steps.set_environment_name.outputs.url }}
ENVIRONMENT_NAME: ${{ inputs.environment-name }}

branding:
icon: upload-cloud
color: orange
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdir -p ~/.ssh && chmod 0700 ~/.ssh
cat ${GITHUB_ACTION_PATH}/known_hosts >> ~/.ssh/known_hosts

platform project:set-remote ${PLATFORM_PROJECT_ID}
PLATFORM_OPTS="-vv --activate --target ${GITHUB_REF_NAME}"
PLATFORM_OPTS="-vv --activate --target $ENVIRONMENT_NAME"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PLATFORM_OPTS="-vv --activate --target $ENVIRONMENT_NAME"
[[ "$ENVIRONMENT_NAME" == "" ]] && ENVIRONMENT_NAME="$GITHUB_REF_NAME"
PLATFORM_OPTS="-vv --activate --target $ENVIRONMENT_NAME"

if [[ -n "$FORCE_PUSH" ]]; then
PLATFORM_OPTS="$PLATFORM_OPTS --force"
fi
Expand Down