From 032ee5f9460eea0824b2c53f1ce23ef1e6d246ad Mon Sep 17 00:00:00 2001 From: Yongun Seong Date: Thu, 10 Aug 2023 18:23:03 +0900 Subject: [PATCH] feat(ci): initial attempt at cd manifest deployment --- .github/workflows/build.yaml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 82a2569..7703137 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,6 +15,9 @@ permissions: jobs: build: runs-on: ubuntu-latest + outputs: + image: '${{ vars.ECR_URL }}/${{ vars.IMAGE_NAME }}' + tag: '${{ steps.vars.outputs.image-tag }}' steps: - name: Checkout uses: actions/checkout@v3 @@ -23,6 +26,18 @@ jobs: with: role-to-assume: ${{ vars.ECR_PUSH_ROLE_ARN }} aws-region: ap-northeast-2 + + - name: Set variables + id: vars + env: + REV: ${{ github.ref }} + run: | + date="$(date -u date -u +%Y%m%d)" + short_rev="$(git rev-parse --short "$REV")" + echo "date=$date" >> $GITHUB_OUTPUT + echo "short-rev=$short_rev" >> $GITHUB_OUTPUT + echo "image-tag=${date}-${short_rev}" + - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v1 @@ -33,6 +48,16 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} - tags: ${{ vars.ECR_URL }}/${{ vars.IMAGE_NAME }}:latest + tags: ${{ vars.ECR_URL }}/${{ vars.IMAGE_NAME }}:${{ steps.vars.outputs.image-tag }} cache-from: type=gha cache-to: type=gha,mode=max + deploy: + needs: build + uses: bacchus-snu/cd-manifests/.github/workflows/deploy-application.yaml + with: + application: bacchus-snu/id/dev + image: ${{ needs.build.outputs.image }} + tag: ${{ needs.build.outputs.tag }} + secrets: + app-id: '${{ secrets.CD_GITHUB_APP_ID }}' + app-private-key: '${{ secrets.CD_GITHUB_APP_SECRET_KEY }}'