Skip to content

Commit

Permalink
Merge pull request #9 from 2000yeshu/feature/arch
Browse files Browse the repository at this point in the history
Add arch environment variable
  • Loading branch information
unfor19 committed Nov 12, 2021
2 parents 142eec8 + 1f5dacb commit 1fb6bab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Add the following step to a job in your workflow
with:
version: 2 # default
verbose: false # default
arch: x86 # default
```

### Full example
Expand Down Expand Up @@ -93,4 +94,16 @@ jobs:
version: 2.0.30
- run: aws --version
shell: bash

test_arm:
runs-on: ubuntu-latest
name: arm architecture
steps:
- uses: actions/checkout@v2
- id: install-aws-cli
uses: unfor19/install-aws-cli-action@v1
with:
arch: aarch64
- run: aws --version
shell: bash
```
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ inputs:
description: "Install lightsailctl plugin"
required: false
default: false
arch:
description: Architecture of the linux host
required: false
default: x86
outputs:
version:
description: "The AWS CLI version that was installed"
Expand All @@ -30,6 +34,7 @@ runs:
echo "AWS_CLI_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
echo "VERBOSE=${{ inputs.verbose }}" >> $GITHUB_ENV
echo "LIGHTSAILCTL=${{ inputs.lightsailctl }}" >> $GITHUB_ENV
echo "ARCH=${{ inputs.arch }}" >> $GITHUB_ENV
shell: bash
- id: install-aws-cli
run: sudo --preserve-env ${{ github.action_path }}/entrypoint.sh
Expand Down
10 changes: 9 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ _AWS_CLI_VERSION=${_AWS_CLI_VERSION^^} # All uppercase
_AWS_CLI_VERSION=${_AWS_CLI_VERSION//V/} # Remove "V"
_AWS_CLI_VERSION=${_AWS_CLI_VERSION:-$_DEFAULT_VERSION}
_DOWNLOAD_URL=""
_DEFAULT_ARCH="x86"
_ARCH=${_ARCH^^}
_ARCH=${_ARCH:-$_DEFAULT_ARCH}
_LIGHTSAIL_INSTALL=${LIGHTSAILCTL:-"false"}

msg_error(){
Expand Down Expand Up @@ -59,8 +62,13 @@ valid_semantic_version(){

set_download_url(){
msg_log "Setting _DOWNLOAD_URL"
# If arch is aarch64 provided, bypass version check because:
# 1. Only version 2 is available for aarch64
# 2. Give arch priority over version(if both provided)
if [[ $_ARCH = "AARCH64" ]]; then
_DOWNLOAD_URL = "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"
# v1
if [[ $_AWS_CLI_VERSION =~ ^1.*$ ]]; then
elif [[ $_AWS_CLI_VERSION =~ ^1.*$ ]]; then
if [[ $_AWS_CLI_VERSION = "1" ]]; then
_DOWNLOAD_URL="https://s3.amazonaws.com/aws-cli/awscli-bundle.zip"
else
Expand Down

0 comments on commit 1fb6bab

Please sign in to comment.