From e0568d0ae2e3abeb61d08050ba5b54ff075451d5 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Wed, 27 Dec 2023 18:50:58 -1000 Subject: [PATCH] Experiment with Building Image from Github Actions --- .github/workflows/deploy-to-control-plane.yml | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/deploy-to-control-plane.yml diff --git a/.github/workflows/deploy-to-control-plane.yml b/.github/workflows/deploy-to-control-plane.yml new file mode 100644 index 00000000..be0742f2 --- /dev/null +++ b/.github/workflows/deploy-to-control-plane.yml @@ -0,0 +1,66 @@ +# Control Plane GitHub Action + +name: Deploy-To-Control-Plane + +# Controls when the workflow will run +on: + # Uncomment the lines you want actions that will cause the workflow to Triggers the workflow on push or pull request events but only for the main branch + + # push: + # branches: [main] + # pull_request: + # branches: [main] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Convert the GitHub secret variables to environment variables for use by the Control Plane CLI +env: + CPLN_ORG: ${{secrets.CPLN_ORG}} + CPLN_TOKEN: ${{secrets.CPLN_TOKEN}} + +jobs: + deploy-to-control-plane: + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' # Specify your Ruby version here + + - name: Install Control Plane CLI + shell: bash + run: | + sudo npm install -g @controlplane/cli + cpln --version + gem install cpl -v 1.1.2 + + - name: setup-control-plane-tools-staging + run: | + cpln profile create default --token ${{ secrets.CPLN_TOKEN_STAGING }} --org ${{ secrets.CPLN_TOKEN_STAGING }} --gvc ${{ secrets.APP_NAME_STAGING }} + cpln image docker-login + + - name: Set Short SHA + id: vars + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + + - name: Get short SHA + id: short_sha + run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + + - name: Containerize and push image + run: | + cpl build-image -a ${{ secrets.APP_NAME_STAGING }} --commit ${env.SHORT_SHA::7} +# # Containerize and push the application to the org's private image repository. The tag is the short SHA of the commit. +# - name: Containerize application and push image +# shell: bash +# run: | +# cpln profile update default --token ${CPLN_TOKEN} +# cpln image docker-login +# cpln image build --name ${CPLN_IMAGE}:${{steps.vars.outputs.sha_short}} --dockerfile ./Dockerfile --push +## +## build-and-push: