Closed erichartline closed 4 years ago
Frontend
name: Pull Request Deployment
on:
pull_request:
types: [labeled, synchronize]
jobs:
build:
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
- name: set up vars
id: vars
run: |
echo ::set-output name=short_sha::$(git rev-parse --short HEAD)
if [ ${{ github.event.pull_request.user.login }} == "wildlifehexagon" ]
then
echo ::set-output name=cluster::"erickube"
echo ::set-output name=docker_path::"docker/eric-dev/Dockerfile"
elif [ ${{ github.event.pull_request.user.login }} == "cybersiddhu" ]
then
echo ::set-output name=cluster::"siddkube"
echo ::set-output name=docker_path::"docker/sidd-dev/Dockerfile"
else
exit 1
fi
- name: image build and push
if: ${{ success() }}
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: dictybase/${{ github.event.pull_request.head.repo.name }}
add_git_labels: true
tag_with_sha: true
tag_with_ref: true
tags: pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.short_sha }}
dockerfile: ${{ steps.vars.outputs.docker_path }}
- name: prepare for deploy
if: ${{ success() }}
id: prepare_deploy
uses: dictybase-docker/prepare-deploy@v1
with:
cluster-name: ${{ steps.vars.outputs.cluster }}
cluster-zone: "us-central1-a"
namespace: dictybase
chart-name: ${{ github.event.pull_request.head.repo.name }}
chart-path: charts/${{ github.event.pull_request.head.repo.name }}
token: ${{ secrets.GITHUB_TOKEN }}
image-tag: pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.short_sha }}
ref: ${{ github.head_ref }}
artifact: ${{ github.event.pull_request.head.repo.name }}
environment: development
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: check out code
uses: actions/checkout@v2
- name: download deployment artifact
uses: actions/download-artifact@v2
with:
name: ${{ github.event.repository.name }}
- name: download and setup path for github action binary
run: |
mkdir -p github-actions/bin
curl -L -o github-actions/bin/actions https://github.com/dictybase-docker/github-actions/releases/download/v0.0.2/action_0.0.2_Linux_x86_64
chmod +x github-actions/bin/actions
echo "::add-path::$GITHUB_WORKSPACE/github-actions/bin"
- name: extract information from deployment payload
id: deploy_info
run: actions --log-level debug sdp -f deployment.json
- name: set in_progress deployment status
if: ${{ success() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state in_progress --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
- name: setup google cloud sdk
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: "299.0.0"
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.SA_KEY }}
export_default_credentials: true
- name: set up helm
uses: azure/setup-helm@v1
with:
version: "v2.16.9"
- name: get gcloud credentials for k8s cluster
run: gcloud container clusters get-credentials --project ${{ secrets.PROJECT_ID }} --zone ${{ steps.deploy_info.outputs.zone }} ${{ steps.deploy_info.outputs.cluster }}
- name: deploy chart
if: ${{ success() }}
run: actions --log-level debug dc --name ${{ steps.deploy_info.outputs.chart }} --namespace ${{ steps.deploy_info.outputs.namespace }} --image-tag ${{ steps.deploy_info.outputs.image_tag }} --path ${{ steps.deploy_info.outputs.path }}
- name: set successful deploy status
if: ${{ success() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state success --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
- name: set unsuccessful deploy status
if: ${{ failure() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state error --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
Frontend (assignees)
name: Pull Request Deployment for Assignees
on:
pull_request:
types: [assigned, synchronize]
jobs:
build:
strategy:
fail-fast: false
matrix:
assignee: ${{ github.event.pull_request.assignees.*.login }}
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
- name: set vars
id: vars
run: |
echo ::set-output name=short_sha::$(git rev-parse --short HEAD)
if [ ${{ matrix.assignee }} == "wildlifehexagon" ]
then
echo ::set-output name=cluster::"erickube"
echo ::set-output name=docker_path::"docker/eric-dev/Dockerfile"
elif [ ${{ matrix.assignee }} == "cybersiddhu" ]
then
echo ::set-output name=cluster::"siddkube"
echo ::set-output name=docker_path::"docker/sidd-dev/Dockerfile"
else
exit 1
fi
- name: image build and push
if: ${{ success() }}
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: dictybase/${{ github.event.pull_request.head.repo.name }}
add_git_labels: true
tag_with_sha: true
tag_with_ref: true
tags: pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.short_sha }}
dockerfile: ${{ steps.vars.outputs.docker_path }}
- name: prepare for deploy
if: ${{ success() }}
id: prepare_deploy
uses: dictybase-docker/prepare-deploy@v1
with:
cluster-name: ${{ steps.vars.outputs.cluster }}
cluster-zone: "us-central1-a"
namespace: dictybase
chart-name: ${{ github.event.pull_request.head.repo.name }}
chart-path: charts/${{ github.event.pull_request.head.repo.name }}
token: ${{ secrets.GITHUB_TOKEN }}
image-tag: pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.short_sha }}
ref: ${{ github.head_ref }}
artifact: ${{ matrix.assignee }}-${{ github.event.pull_request.head.repo.name }}
environment: development
deploy:
strategy:
fail-fast: false
matrix:
assignee: ${{ github.event.pull_request.assignees.*.login }}
runs-on: ubuntu-latest
needs: build
steps:
- name: check out code
uses: actions/checkout@v2
- name: download deployment artifact
uses: actions/download-artifact@v2
with:
name: ${{ matrix.assignee }}-${{ github.event.repository.name }}
- name: download and setup path for github action binary
run: |
mkdir -p github-actions/bin
curl -L -o github-actions/bin/actions https://github.com/dictybase-docker/github-actions/releases/download/v0.0.2/action_0.0.2_Linux_x86_64
chmod +x github-actions/bin/actions
echo "::add-path::$GITHUB_WORKSPACE/github-actions/bin"
- name: extract information from deployment payload
id: deploy_info
run: actions --log-level debug sdp -f deployment.json
- name: set in_progress deployment status
if: ${{ success() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state in_progress --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
- name: setup google cloud sdk
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: "299.0.0"
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.SA_KEY }}
export_default_credentials: true
- name: set up helm
uses: azure/setup-helm@v1
with:
version: "v2.16.9"
- name: get gcloud credentials for k8s cluster
run: gcloud container clusters get-credentials --project ${{ secrets.PROJECT_ID }} --zone ${{ steps.deploy_info.outputs.zone }} ${{ steps.deploy_info.outputs.cluster }}
- name: deploy chart
if: ${{ success() }}
run: actions --log-level debug dc --name ${{ steps.deploy_info.outputs.chart }} --namespace ${{ steps.deploy_info.outputs.namespace }} --image-tag ${{ steps.deploy_info.outputs.image_tag }} --path ${{ steps.deploy_info.outputs.path }}
- name: set successful deploy status
if: ${{ success() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state success --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
- name: set unsuccessful deploy status
if: ${{ failure() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state error --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
Backend
name: Pull Request Deployment
on:
pull_request:
types: [labeled, synchronize]
jobs:
build:
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
- name: get short sha and cluster name
id: vars
run: |
echo ::set-output name=short_sha::$(git rev-parse --short HEAD)
if [ ${{ github.event.pull_request.user.login }} == "wildlifehexagon" ]
then
echo ::set-output name=cluster::"erickube"
elif [ ${{ github.event.pull_request.user.login }} == "cybersiddhu" ]
then
echo ::set-output name=cluster::"siddkube"
else
exit 1
fi
- name: image build and push
if: ${{ success() }}
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: dictybase/${{ github.event.pull_request.head.repo.name }}
add_git_labels: true
tag_with_sha: true
tag_with_ref: true
tags: pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.short_sha }}
dockerfile: build/package/Dockerfile
- name: prepare for deploy
if: ${{ success() }}
id: prepare_deploy
uses: dictybase-docker/prepare-deploy@v1
with:
cluster-name: ${{ steps.vars.outputs.cluster }}
cluster-zone: "us-central1-a"
namespace: dictybase
chart-name: ${{ github.event.pull_request.head.repo.name }}
chart-path: deployments/charts/${{ github.event.pull_request.head.repo.name }}
token: ${{ secrets.GITHUB_TOKEN }}
image-tag: pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.short_sha }}
ref: ${{ github.head_ref }}
artifact: ${{ github.event.pull_request.head.repo.name }}
environment: development
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: check out code
uses: actions/checkout@v2
- name: download deployment artifact
uses: actions/download-artifact@v2
with:
name: ${{ github.event.repository.name }}
- name: download and setup path for github action binary
run: |
mkdir -p github-actions/bin
curl -L -o github-actions/bin/actions https://github.com/dictybase-docker/github-actions/releases/download/v0.0.2/action_0.0.2_Linux_x86_64
chmod +x github-actions/bin/actions
echo "::add-path::$GITHUB_WORKSPACE/github-actions/bin"
- name: extract information from deployment payload
id: deploy_info
run: actions --log-level debug sdp -f deployment.json
- name: set in_progress deployment status
if: ${{ success() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state in_progress --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
- name: setup google cloud sdk
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: "299.0.0"
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.SA_KEY }}
export_default_credentials: true
- name: set up helm
uses: azure/setup-helm@v1
with:
version: "v2.16.9"
- name: get gcloud credentials for k8s cluster
run: gcloud container clusters get-credentials --project ${{ secrets.PROJECT_ID }} --zone ${{ steps.deploy_info.outputs.zone }} ${{ steps.deploy_info.outputs.cluster }}
- name: deploy chart
if: ${{ success() }}
run: actions --log-level debug dc --name ${{ steps.deploy_info.outputs.chart }} --namespace ${{ steps.deploy_info.outputs.namespace }} --image-tag ${{ steps.deploy_info.outputs.image_tag }} --path ${{ steps.deploy_info.outputs.path }}
- name: set successful deploy status
if: ${{ success() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state success --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
- name: set unsuccessful deploy status
if: ${{ failure() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state error --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
Backend (assignees)
name: Pull Request Deployment for Assignees
on:
pull_request:
types: [assigned, synchronize]
jobs:
build:
strategy:
fail-fast: false
matrix:
assignee: ${{ github.event.pull_request.assignees.*.login }}
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
- name: get short sha and cluster name
id: vars
run: |
echo ::set-output name=short_sha::$(git rev-parse --short HEAD)
if [ ${{ matrix.assignee }} == "wildlifehexagon" ]
then
echo ::set-output name=cluster::"erickube"
elif [ ${{ matrix.assignee }} == "cybersiddhu" ]
then
echo ::set-output name=cluster::"siddkube"
else
exit 1
fi
- name: image build and push
if: ${{ success() }}
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: dictybase/${{ github.event.pull_request.head.repo.name }}
add_git_labels: true
tag_with_sha: true
tag_with_ref: true
tags: pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.short_sha }}
dockerfile: build/package/Dockerfile
- name: prepare for deploy
if: ${{ success() }}
id: prepare_deploy
uses: dictybase-docker/prepare-deploy@v1
with:
cluster-name: ${{ steps.vars.outputs.cluster }}
cluster-zone: "us-central1-a"
namespace: dictybase
chart-name: ${{ github.event.pull_request.head.repo.name }}
chart-path: deployments/charts/${{ github.event.pull_request.head.repo.name }}
token: ${{ secrets.GITHUB_TOKEN }}
image-tag: pr-${{ github.event.pull_request.number }}-${{ steps.vars.outputs.short_sha }}
ref: ${{ github.head_ref }}
artifact: ${{ matrix.assignee }}-${{ github.event.pull_request.head.repo.name }}
environment: development
deploy:
strategy:
fail-fast: false
matrix:
assignee: ${{ github.event.pull_request.assignees.*.login }}
runs-on: ubuntu-latest
needs: build
steps:
- name: check out code
uses: actions/checkout@v2
- name: download deployment artifact
uses: actions/download-artifact@v2
with:
name: ${{ matrix.assignee }}-${{ github.event.repository.name }}
- name: download and setup path for github action binary
run: |
mkdir -p github-actions/bin
curl -L -o github-actions/bin/actions https://github.com/dictybase-docker/github-actions/releases/download/v0.0.2/action_0.0.2_Linux_x86_64
chmod +x github-actions/bin/actions
echo "::add-path::$GITHUB_WORKSPACE/github-actions/bin"
- name: extract information from deployment payload
id: deploy_info
run: actions --log-level debug sdp -f deployment.json
- name: set in_progress deployment status
if: ${{ success() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state in_progress --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
- name: setup google cloud sdk
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: "299.0.0"
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.SA_KEY }}
export_default_credentials: true
- name: set up helm
uses: azure/setup-helm@v1
with:
version: "v2.16.9"
- name: get gcloud credentials for k8s cluster
run: gcloud container clusters get-credentials --project ${{ secrets.PROJECT_ID }} --zone ${{ steps.deploy_info.outputs.zone }} ${{ steps.deploy_info.outputs.cluster }}
- name: deploy chart
if: ${{ success() }}
run: actions --log-level debug dc --name ${{ steps.deploy_info.outputs.chart }} --namespace ${{ steps.deploy_info.outputs.namespace }} --image-tag ${{ steps.deploy_info.outputs.image_tag }} --path ${{ steps.deploy_info.outputs.path }}
- name: set successful deploy status
if: ${{ success() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state success --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
- name: set unsuccessful deploy status
if: ${{ failure() }}
run: actions --log-level debug -t ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} -r ${{ github.event.repository.name }} ds --state error --deployment_id ${{ steps.deploy_info.outputs.id }} --url ${{ steps.deploy_info.outputs.url }}
This is being tested at https://github.com/dictybase-playground/auto-deploy
There is a new workflow that uses the /deploy
command. It has a step that uses a conditional-heavy shell script. This needs to be fine-tuned, especially in terms of the short-sha
variable which isn't correctly grabbing the commit ID for that particular request.
Follow the guidelines at #138