-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #733 from overlordtm/master
New deploy workflows
- Loading branch information
Showing
12 changed files
with
472 additions
and
61 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: PR Cleanup | ||
|
||
on: | ||
pull_request: | ||
types: [closed, unlabeled] | ||
|
||
env: | ||
DEPLOY_NAMESPACE: sledilnik-pr | ||
RELEASE_NAME: website-pr-${{ github.event.pull_request.number }} | ||
DEPLOY_ENV: pr-${{ github.event.pull_request.number }} | ||
|
||
jobs: | ||
undeploy: | ||
if: "github.event.action == 'closed' || !contains(github.event.pull_request.labels.*.name, 'deploy-preview')" | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Debug | ||
uses: hmarr/[email protected] | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Undeploy | ||
uses: sledilnik/action-helm-deploy@v1 | ||
with: | ||
action: undeploy | ||
chartName: sledilnik/website | ||
chartVersion: '0.9.0' | ||
kubeconfig: '${{ secrets.KUBECONFIG }}' | ||
|
||
- name: Leave success comment on PR | ||
uses: mshick/add-pr-comment@v1 | ||
if: ${{ success() }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
message: | | ||
Undeployed PR | ||
allow-repeats: true | ||
|
||
- name: Leave failure comment on PR | ||
uses: mshick/add-pr-comment@v1 | ||
if: ${{ failure() }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
message: | | ||
Undeploy failed | ||
allow-repeats: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
name: Build and deploy (pull request) | ||
|
||
on: | ||
pull_request: | ||
types: [synchronize, reopened, labeled] | ||
|
||
env: | ||
RELEASE_NAME: website-pr-${{ github.event.pull_request.number }} | ||
CHART_VALUES_FILE: .helm/values.pr.yml | ||
DEPLOY_NAMESPACE: sledilnik-pr | ||
DEPLOY_ENV: pr-${{ github.event.pull_request.number }} | ||
DEPLOY_URL: https://pr-${{ github.event.pull_request.number }}.preview.sledilnik.org | ||
IMAGE_TAG: pr-${{ github.event.pull_request.number }} | ||
INGRESS_RULE: Host(`pr-${{ github.event.pull_request.number }}.preview.sledilnik.org`) | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Debug | ||
uses: hmarr/[email protected] | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: '14' | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | ||
|
||
- uses: actions/cache@v2 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- run: yarn | ||
- run: yarn lint | ||
- run: yarn test | ||
- run: yarn dotnet-restore | ||
- run: yarn test-fsharp | ||
|
||
build: | ||
if: contains(github.event.pull_request.labels.*.name, 'deploy-preview') | ||
needs: test | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to ghcr.io | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
|
||
- name: Build and push docker container image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
context: . | ||
file: ./Dockerfile | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/website:${{ env.IMAGE_TAG}} | ||
deploy: | ||
runs-on: ubuntu-20.04 | ||
if: contains(github.event.pull_request.labels.*.name, 'deploy-preview') | ||
needs: build | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Deploy | ||
uses: sledilnik/action-helm-deploy@v1 | ||
with: | ||
chartName: sledilnik/website | ||
chartVersion: '0.9.0' | ||
kubeconfig: '${{ secrets.KUBECONFIG }}' | ||
|
||
- name: PR comment (success) | ||
uses: mshick/add-pr-comment@v1 | ||
if: ${{ success() }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
message: | | ||
Deployed PR-${{ github.event.pull_request.number }} to ${{ env.DEPLOY_URL }} | ||
allow-repeats: true | ||
|
||
- name: PR comment (failure) | ||
uses: mshick/add-pr-comment@v1 | ||
if: ${{ failure() }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
message: | | ||
Deploy of PR-${{ github.event.pull_request.number }} failed | ||
allow-repeats: true | ||
|
||
- name: Slack notification | ||
uses: 8398a7/action-slack@v3 | ||
with: | ||
icon_url: 'https;//github.com/sledilnik.png?size=32' | ||
author_name: 'Deploy bot' | ||
status: custom | ||
fields: repo,workflow,job | ||
custom_payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "PR-${{ github.event.pull_request.number}} deploy finished with status: ${{ job.status }}" | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "URL: ${{ env.DEPLOY_URL }}" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Build and deploy (production) | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
RELEASE_NAME: website | ||
CHART_VALUES_FILE: .helm/values.prod.yml | ||
DEPLOY_NAMESPACE: sledilnik-prod | ||
DEPLOY_ENV: production | ||
DEPLOY_URL: https://covid-19.sledilnik.org | ||
IMAGE_TAG: ${{ github.event.release.tag_name }} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Debug | ||
uses: hmarr/[email protected] | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: '14' | ||
- run: yarn | ||
- run: yarn lint | ||
- run: yarn test | ||
- run: yarn dotnet-restore | ||
- run: yarn test-fsharp | ||
|
||
build: | ||
runs-on: ubuntu-20.04 | ||
needs: test | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to ghcr.io | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
|
||
- name: Build and push docker container image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
context: . | ||
file: ./Dockerfile | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/website:${{ env.IMAGE_TAG}} | ||
deploy: | ||
runs-on: ubuntu-20.04 | ||
needs: build | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Deploy | ||
uses: sledilnik/action-helm-deploy@v1 | ||
with: | ||
chartName: sledilnik/website | ||
chartVersion: '0.9.0' | ||
kubeconfig: '${{ secrets.KUBECONFIG }}' | ||
|
||
- name: Slack notification | ||
uses: 8398a7/action-slack@v3 | ||
with: | ||
icon_url: 'https;//github.com/sledilnik.png?size=32' | ||
author_name: 'Deploy bot' | ||
status: custom | ||
fields: repo,workflow,job | ||
custom_payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "Production deploy finished with status: ${{ job.status }}" | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "URL: ${{ env.DEPLOY_URL }}" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} |
Oops, something went wrong.