Created
December 29, 2021 06:54
-
-
Save itsmunim/71e3ce58b40e26bcf0e16d5e9d7d2937 to your computer and use it in GitHub Desktop.
A github action workflow, which gets triggered if a PR is opened against master, does deployment from the PR to a DO kubernetes cluster
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: deploy-from-pr | |
on: | |
pull_request: | |
branches: | |
- master | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
deploy-from-pr: | |
name: Deploy from PR to Development | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set version | |
id: release | |
run: echo ::set-output name=version::$(git describe --always) | |
# custom action to build and push image | |
- name: Build & publish image | |
uses: ./.github/actions/publish-image | |
with: | |
registry: ${{ env.REGISTRY }} | |
registry_username: ${{ github.REGISTRY_USERNAME }} | |
registry_password: ${{ secrets.REGISTRY_PASSWORD }} | |
image_name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tag: ${{ steps.release.outputs.version }} | |
# custom action to deploy into kubernetes | |
- name: Deploy to kubernetes | |
uses: ./.github/actions/deploy-to-k8s | |
with: | |
digitalocean_token: ${{ secrets.DIGITALOCEAN_TOKEN }} | |
cluster_name: ${{ secrets.CLUSTER_NAME }} | |
overlay_path: .k8s/overlays/dev | |
image_name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tag: ${{ steps.release.outputs.version }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment