diff options
author | 2023-03-06 12:59:39 +0100 | |
---|---|---|
committer | 2023-03-06 12:59:39 +0100 | |
commit | 63c5febc532e93c20458a57432fab24d917a7309 (patch) | |
tree | c01cc8adf639d1108859073ab779d52e6b5d9050 | |
parent | Merge pull request #896 from python-discord/dependabot/pip/django-environ-0.10.0 (diff) |
merge buid & deploy CIs
-rw-r--r-- | .github/workflows/build-deploy.yaml (renamed from .github/workflows/build.yaml) | 58 | ||||
-rw-r--r-- | .github/workflows/deploy.yaml | 52 |
2 files changed, 44 insertions, 66 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build-deploy.yaml index bf9ec5b7..cdfc84f9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build-deploy.yaml @@ -1,26 +1,20 @@ -name: Build +name: Build & Deploy on: - workflow_run: - workflows: ["Lint & Test"] - branches: - - main - types: - - completed + workflow_call: + inputs: + sha-tag: + description: "A short-form SHA tag for the commit that triggered this workflow" + required: true + type: string + jobs: build: name: Build Docker Image - if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' runs-on: ubuntu-latest steps: - # Create a commit SHA-based tag for the container repositories - - name: Create SHA Container Tag - id: sha_tag - run: | - tag=$(cut -c 1-7 <<< $GITHUB_SHA) - echo "tag=$tag" >> $GITHUB_OUTPUT - name: Checkout code uses: actions/checkout@v3 @@ -56,3 +50,39 @@ jobs: ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }} build-args: | git_sha=${{ github.sha }} + + deploy: + name: Deploy + needs: build + runs-on: ubuntu-latest + environment: production + + steps: + # Check out the private Kubernetes repository for the + # deployment.yaml file using a GitHub Personal Access + # Token to get access. + - name: Checkout code + uses: actions/checkout@v3 + with: + repository: python-discord/kubernetes + + - uses: azure/setup-kubectl@v3 + + - name: Authenticate with Kubernetes + uses: azure/k8s-set-context@v3 + with: + method: kubeconfig + kubeconfig: ${{ secrets.KUBECONFIG }} + + - name: Deploy to Kubernetes + uses: Azure/k8s-deploy@v4 + with: + manifests: | + namespaces/default/site/deployment.yaml + images: 'ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}' + + - name: Purge Cloudflare Edge Cache + uses: jakejarvis/cloudflare-purge-action@master + env: + CLOUDFLARE_ZONE: 989c984a358bfcd1e9b9d188cc86c1df + CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml deleted file mode 100644 index f27690f0..00000000 --- a/.github/workflows/deploy.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: Deploy - -on: - workflow_run: - workflows: ["Build"] - branches: - - main - types: - - completed - -jobs: - deploy: - if: github.event.workflow_run.conclusion == 'success' - name: Deploy to Kubernetes Cluster - runs-on: ubuntu-latest - environment: production - - steps: - - name: Create SHA Container Tag - id: sha_tag - run: | - tag=$(cut -c 1-7 <<< $GITHUB_SHA) - echo "tag=$tag" >> $GITHUB_OUTPUT - - # Check out the private Kubernetes repository for the - # deployment.yaml file using a GitHub Personal Access - # Token to get access. - - name: Checkout code - uses: actions/checkout@v3 - with: - repository: python-discord/kubernetes - - - uses: azure/setup-kubectl@v3 - - - name: Authenticate with Kubernetes - uses: azure/k8s-set-context@v3 - with: - method: kubeconfig - kubeconfig: ${{ secrets.KUBECONFIG }} - - - name: Deploy to Kubernetes - uses: Azure/k8s-deploy@v4 - with: - manifests: | - namespaces/default/site/deployment.yaml - images: 'ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}' - - - name: Purge Cloudflare Edge Cache - uses: jakejarvis/cloudflare-purge-action@master - env: - CLOUDFLARE_ZONE: 989c984a358bfcd1e9b9d188cc86c1df - CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} |