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

CD : secrets 참조 에러 #12

Merged
merged 2 commits into from
Jul 26, 2023
Merged

CD : secrets 참조 에러 #12

merged 2 commits into from
Jul 26, 2023

Conversation

yooniversal
Copy link
Contributor

secrets 참조 에러

secrets에 저장했던 application.yml, application-oauth.yml 정보를 직접 참조해서 사용했는데 다음 에러가 발생했습니다.

echo "***
    ***
          **
...
      ***
  " > ./src/main/resources/application.yml
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    AWS_REGION: ap-northeast-2
    S3_BUCKET_NAME: fittering-bucket-test
    CODE_DEPLOY_APPLICATION_NAME: fittering-codedeploy-app
    CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: fittering-codedeploy-group
    JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.7-7/x64
    JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.7-7/x64
    GRADLE_BUILD_ACTION_CACHE_RESTORED: true
    AWS_DEFAULT_REGION: ap-northeast-2
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
/home/runner/work/_temp/103966c5-f671-435c-bc34-a73f8c8b58c9.sh: line 100: ***
...
      ***
: bad substitution
Error: Process completed with exit code 1.

아래는 deploy.yml에서 문제가 발생한 코드입니다.
${{ secrets.APP_SECRET }}에서 위 에러가 발생했습니다.

...
# application.yml
- name:  make application.yml
  run: touch ./src/main/resources/application.yml
  shell: bash
- name: deliver application.yml
  run: echo "${{ secrets.APP_SECRET }}" > ./src/main/resources/application.yml # **문제 발생**
  shell: bash

actions/runner에서 이와 비슷한 문제를 다루는 issue가 있는걸 확인했고 인식을 제대로 하지못해 발생하는 문제로 보입니다.
임시 방편으로 참조하려는 내용을 환경변수 env에 저장한 후 사용하면 해결할 수 있다는 언급이 있어 그렇게 수정했습니다.

- name: deliver application.yml
  env:
    APPLICATION: ${{ secrets.APP_SECRET }}
  run: echo $APPLICATION >> ./src/main/resources/application.yml

References

@yooniversal yooniversal linked an issue Jul 26, 2023 that may be closed by this pull request
@yooniversal yooniversal merged commit 985a618 into main Jul 26, 2023
1 check passed
@yooniversal yooniversal deleted the 11-cd-secrets-resolve branch July 26, 2023 19:21
@yooniversal
Copy link
Contributor Author

env로 등록해 활용해도 해결되지 않아 인코딩된 값을 secrets로 관리하도록 했습니다: #17

@yooniversal yooniversal added the ✘ Invalid This doesn't seem right label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✘ Invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CD : secrets 변수 인식 못함
1 participant