Skip to content

Commit

Permalink
getting to learn GitHub actions secret management
Browse files Browse the repository at this point in the history
  • Loading branch information
Izaim committed Mar 25, 2024
1 parent 1331799 commit 2440dfb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/test_coverage_with_tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
COGNITO_INIT: ${{ secrets.COGNITO_INIT }}
COGNITO_USER_POOL_ID: ${{ secrets.COGNITO_USER_POOL_ID }}
COGNITO_CLIENT_ID: ${{ secrets.COGNITO_CLIENT_ID }}
COGNITO_AUTH_FLOW: ${{ secrets.COGNITO_AUTH_FLOW }}
COGNITO_USERNAME: ${{ secrets.COGNITO_USERNAME }}
COGNITO_PASSWORD: ${{ secrets.COGNITO_PASSWORD }}

run: |
pip install awscli
OUTPUT=$(aws cognito-idp admin-initiate-auth --user-pool-id ${{ secrets.COGNITO_USER_POOL_ID }} --client-id ${{ secrets.COGNITO_CLIENT_ID }} --auth-flow ${{ secrets.COGNITO_AUTH_FLOW }} --auth-parameters USERNAME=${{ secrets.COGNITO_USERNAME }},PASSWORD=${{ secrets.COGNITO_PASSWORD }})
OUTPUT=$(aws cognito-idp $COGNITO_INIT --user-pool-id $COGNITO_USER_POOL_ID --client-id $COGNITO_CLIENT_ID --auth-flow $COGNITO_AUTH_FLOW --auth-parameters USERNAME=$COGNITO_USERNAME,PASSWORD=$COGNITO_PASSWORD)
export ACCESS_TOKEN=$(echo "$OUTPUT" | jq -r '.AuthenticationResult.AccessToken' | sed 's/^"\(.*\)"$/\1/')
export ID_TOKEN=$(echo "$OUTPUT" | jq -r '.AuthenticationResult.IdToken' | sed 's/^"\(.*\)"$/\1/')
Expand All @@ -59,6 +66,6 @@ jobs:
run: pytest --cov --cov-fail-under=85
env:
CRIPT_HOST: https://lb-stage.mycriptapp.org/
CRIPT_TOKEN: ${{ steps.cognito.outputs.ID_TOKEN }}
CRIPT_STORAGE_TOKEN: ${{ steps.cognito.outputs.ACCESS_TOKEN }}
CRIPT_TOKEN: $ID_TOKEN
CRIPT_STORAGE_TOKEN: $ACCESS_TOKEN
CRIPT_TESTS: False

0 comments on commit 2440dfb

Please sign in to comment.