[MODIFY] transfer 한 file mv 명령에 sudo 추가 #175
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cd-dev | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ develop ] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: ✅ Checkout | |
uses: actions/checkout@v3 | |
- name: ⚙️ Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
cache: gradle | |
- name: 🔒 Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: 🧱 Build Image and Push to ECR | |
env: | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
AWS_ECR_REPO: ${{ secrets.AWS_ECR_REPO_DEV }} | |
run: | | |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws | |
docker build -t $AWS_ECR_REPO . | |
docker tag $AWS_ECR_REPO:latest public.ecr.aws/$AWS_ACCOUNT_ID/$AWS_ECR_REPO:latest | |
docker push public.ecr.aws/$AWS_ACCOUNT_ID/$AWS_ECR_REPO:latest | |
deploy: | |
needs: build-and-push | |
runs-on: ubuntu-latest | |
steps: | |
- name: ✅ Checkout | |
uses: actions/checkout@v3 | |
- name: 🔒 Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: 📝 Copy Files from S3 | |
env: | |
REGION: ${{ secrets.AWS_REGION }} | |
APPLE_KEY_NAME: ${{ secrets.APPLE_KEY_NAME }} | |
S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }} | |
run: | | |
aws s3 cp --region $REGION \ | |
s3://$S3_BUCKET/dev/script/deploy.sh ./deploy.sh | |
aws s3 cp --region $REGION \ | |
s3://$S3_BUCKET/dev/script/switch.sh ./switch.sh | |
aws s3 cp --region $REGION \ | |
s3://$S3_BUCKET/dev/script/valid.sh ./valid.sh | |
aws s3 cp --region $REGION \ | |
s3://$S3_BUCKET/dev/dev.env ./application.env | |
aws s3 cp --region $REGION \ | |
s3://$S3_BUCKET/dev/static/$APPLE_KEY ./$APPLE_KEY_NAME | |
- name: 🔄 Transfer Files to Server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST_DEV }} | |
username: ubuntu | |
key: ${{ secrets.PEM_KEY_DEV }} | |
port: 22 | |
source: "deploy.sh,switch.sh,valid.sh,application.env,${{ secrets.APPLE_KEY_NAME }}" | |
target: /home/ubuntu/deploy-temp/op | |
- name: 🚀SSH command deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST_DEV }} | |
username: ubuntu | |
key: ${{ secrets.PEM_KEY_DEV }} | |
port: 22 | |
script: | | |
mkdir -p /home/ubuntu/script/op | |
mkdir -p /home/ubuntu/property/op | |
mkdir -p /home/ubuntu/env/op | |
sudo mv /home/ubuntu/deploy-temp/op/deploy.sh /home/ubuntu/script/op/deploy.sh | |
sudo mv /home/ubuntu/deploy-temp/op/switch.sh /home/ubuntu/script/op/switch.sh | |
sudo mv /home/ubuntu/deploy-temp/op/valid.sh /home/ubuntu/script/op/valid.sh | |
sudo mv /home/ubuntu/deploy-temp/op/application.env /home/ubuntu/env/op/application.env | |
sudo mv /home/ubuntu/deploy-temp/op/${{ secrets.APPLE_KEY_NAME }} /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY_NAME }} | |
sudo chmod +x /home/ubuntu/script/op/deploy.sh | |
sudo chmod +x /home/ubuntu/script/op/switch.sh | |
sudo chmod +x /home/ubuntu/script/op/valid.sh | |
sudo chmod +r /home/ubuntu/env/op/application.env | |
sudo chmod +r /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY }} | |
/home/ubuntu/script/op/deploy.sh | |
/home/ubuntu/script/op/switch.sh | |
/home/ubuntu/script/op/valid.sh |