Skip to content

Repository files navigation



Cloudtype



클라우드타입 웨비나 #02
GitHub Actions, Private Registry를 활용한
CI/CD 파이프라인 구축하기

목차

🛠️ 준비사항

🗄️ Private Registry

AWS Elastic Registry

토큰 생성 명령어

  • AWS CLI 설치

    curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"sudo installer -pkg AWSCLIV2.pkg -target /
  • AWS 계정 설정

    aws configure
  • AWS 토큰 발급

    aws ecr get-login-password --region ap-northeast-2

GitHub Repository Secrets

  • AWS_ECR_REGISTRY: AWS ECR Registry 주소(리포지토리 경로 제외)
  • AWS_ACCESS_KEY_ID: AWS 액세스 키 ID
  • AWS_SECRET_ACCESS_KEY: AWS 시크릿 액세스 키
  • CLOUDTYPE_TOKEN: 클라우드타입 API 키

GitHub Actions Workflow

name: Create and publish a Docker image to AWS ECR, Deploy to Cloudtypeon:
push:
branches:
- mainenv:
REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }}IMAGE_NAME: [이미지명]jobs:
build-and-push-image:
runs-on: ubuntu-latestpermissions:
contents: readsteps:
- name: Checkout repositoryuses: actions/checkout@v3
- name: Log in to the Container registryuses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1with:
registry: ${{ env.REGISTRY }}username: ${{ secrets.AWS_ACCESS_KEY_ID }}password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Extract metadata (tags, labels) for Dockerid: metauses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}tags: | type=sha - name: Build and push Docker imageuses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4with:
context: .push: truetags: ${{ steps.meta.outputs.tags }}labels: ${{ steps.meta.outputs.labels }}
- name: Deploy to Cloudtypeuses: cloudtype-github-actions/deploy@v1with:
token: ${{ secrets.CLOUDTYPE_TOKEN }}project: [스페이스명]/[프로젝트명]stage: mainyaml: | name: [서비스명] app: container options: ports: [포트번호] image: ${{ steps.meta.outputs.tags }}

GCP Artifact Registry

GitHub Repository Secrets

  • GAR_REGISTRY: Artifact Registry 주소
  • GAR_JSON_KEY: Artifact Registry 서비스 계정 JSON KEY
  • CLOUDTYPE_TOKEN: 클라우드타입 API 키

GitHub Actions Workflow

name: Create and publish a Docker image to GCP Artifact Registry, Deploy to Cloudtypeon:
push:
branches:
- mainenv:
REGISTRY: ${{ secrets.GAR_REGISTRY }}IMAGE_NAME: [이미지명]jobs:
build-and-push-image:
runs-on: ubuntu-latestpermissions:
contents: readsteps:
- name: Checkout repositoryuses: actions/checkout@v3
- name: Log in to the Container registryuses: docker/login-action@v2with:
registry: ${{ env.REGISTRY }}username: _json_keypassword: ${{ secrets.GAR_JSON_KEY }}
- name: Extract metadata (tags, labels) for Dockerid: metauses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}tags: | type=sha - name: Build and push Docker imageuses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4with:
context: .push: truetags: ${{ steps.meta.outputs.tags }}labels: ${{ steps.meta.outputs.labels }}
- name: Deploy to Cloudtypeuses: cloudtype-github-actions/deploy@v1with:
token: ${{ secrets.CLOUDTYPE_TOKEN }}project: [스페이스명]/[프로젝트명]stage: mainyaml: | name: [서비스명] app: container options: ports: [포트번호] image: ${{ steps.meta.outputs.tags }}

📖 References

💬 Contact

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages