Skip to content

Commit

Permalink
Merge pull request #6 from smu-chile/fix/gh-action-images
Browse files Browse the repository at this point in the history
Restore Functionality With SWR Action
  • Loading branch information
fredyolarte authored Sep 1, 2022
2 parents f42a6a7 + a9e3b54 commit 30cf07d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
This Action allows you to create Docker images and push into a SWR repository. Also, it checks if the repository exist, otherwise, it creates it.

## Parameters

| Parameter | Type | Default | Description |
| ------------------- | -------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `huawei_access_key_id` | `string` | | Your HUAWEI access key id |
| `huawei_secret_access_key` | `string` | | Your HUAWEI secret access key |
| `access_key_id` | `string` | | Your HUAWEI access key id |
| `secret_access_key` | `string` | | Your HUAWEI secret access key |
| `swr_registry` | `string` | | Your SWR HUAWEI |
| `repo` | `string` | | Name of your SWR repository |
| `region` | `string` | | Your HUAWEI region |
Expand All @@ -24,18 +25,17 @@ This Action allows you to create Docker images and push into a SWR repository. A
| `swr_namespace` | `string` | `smu-chile` | SWR Organization name |
| `swr_repos` | `string` | | Image repository name |



## Usage

```yaml
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: smu-chile/gh-action-huawei-swr-policy@master
with:
huawei_access_key_id: ${{ secrets.HUAWEI_ACCESS_KEY_ID }}
huawei_secret_access_key: ${{ secrets.HUAWEI_SECRET_ACCESS_KEY }}
access_key_id: ${{ secrets.HUAWEI_ACCESS_KEY_ID }}
secret_access_key: ${{ secrets.HUAWEI_SECRET_ACCESS_KEY }}
swr_registry: ${{ secrets.SWR_REGISTRY }}
region: la-south-2
repo: ${{ github.repository }}
Expand All @@ -53,7 +53,10 @@ jobs:
```
## Reference
* https://github.com/smu-chile/aws-ecr-policy-action
* https://support.huaweicloud.com/intl/en-us/api-swr/swr_02_0101.html
* <https://github.com/smu-chile/aws-ecr-policy-action>
* <https://support.huaweicloud.com/intl/en-us/api-swr/swr_02_0101.html>
## License
The MIT License (MIT)
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ branding:
color: orange
description: Create Docker images and push into a SWR repository. It can create it and attach a policy to store a max amount
inputs:
huawei_access_key_id:
access_key_id:
description: The HUAWEI access key id
required: true
huawei_secret_access_key:
secret_access_key:
description: The HUAWEI secret access key
required: true
swr_registry:
Expand Down
17 changes: 8 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -e
function main() {


sanitize "${INPUT_HUAWEI_ACCESS_KEY_ID}" "huawei_access_key_id"
sanitize "${INPUT_HUAWEI_SECRET_ACCESS_KEY}" "huawei_secret_access_key"
sanitize "${INPUT_ACCESS_KEY_ID}" "access_key_id"
sanitize "${INPUT_SECRET_ACCESS_KEY}" "secret_access_key"
sanitize "${INPUT_REGION}" "region"
sanitize "${INPUT_REPO}" "repo"
sanitize "${INPUT_SWR_REGISTRY}" "swr_registry"
Expand Down Expand Up @@ -56,16 +56,16 @@ function sanitize() {
}

function huawei_configure() {
export HUAWEI_HUAWEI_ACCESS_KEY_ID=${INPUT_HUAWEI_ACCESS_KEY_ID}
export HUAWEI_HUAWEI_SECRET_ACCESS_KEY=${INPUT_HUAWEI_SECRET_ACCESS_KEY}
export HUAWEI_ACCESS_KEY_ID=${INPUT_ACCESS_KEY_ID}
export HUAWEI_SECRET_ACCESS_KEY=${INPUT_SECRET_ACCESS_KEY}
export HUAWEI_DEFAULT_REGION=${INPUT_REGION}
export HUAWEI_LOGIN=$(printf "${INPUT_HUAWEI_ACCESS_KEY_ID}" | openssl dgst -binary -sha256 -hmac "${INPUT_HUAWEI_SECRET_ACCESS_KEY}" | od -An -vtx1 | sed 's/[ \n]//g' | sed 'N;s/\n//')
export HUAWEI_LOGIN=$(printf "${INPUT_ACCESS_KEY_ID}" | openssl dgst -binary -sha256 -hmac "${INPUT_SECRET_ACCESS_KEY}" | od -An -vtx1 | sed 's/[ \n]//g' | sed 'N;s/\n//')

}

function login() {
echo "== START LOGIN"
export LOGIN_COMMAND=$(docker login -u $HUAWEI_DEFAULT_REGION@$HUAWEI_HUAWEI_ACCESS_KEY_ID -p $HUAWEI_LOGIN ${INPUT_SWR_REGISTRY})
export LOGIN_COMMAND=$(docker login -u $HUAWEI_DEFAULT_REGION@$HUAWEI_ACCESS_KEY_ID -p $HUAWEI_LOGIN ${INPUT_SWR_REGISTRY})
echo $LOGIN_COMMAND
echo "== FINISHED LOGIN"
}
Expand Down Expand Up @@ -142,7 +142,6 @@ function create_swr_policy() {
"algorithm": "or",
"rules": [
{
"template": "tag_rule",
"params": {
"num": "5"
},
Expand All @@ -151,10 +150,10 @@ function create_swr_policy() {
"kind": "regexp",
"pattern": "prod-*"
}
]
],
"template": "tag_rule"
}
]
}'
echo "== FINISHED CREATE POLICY"

Expand Down

0 comments on commit 30cf07d

Please sign in to comment.