This repository has been archived by the owner on May 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 336
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 #566 from vuestorefront/CLOUD_121/122_setup_cicd
CLOUD_121/122 setup CI/CD
- Loading branch information
Showing
1 changed file
with
141 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
name: Deploy to Demo and Test | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: "12.x" | ||
|
||
# Build for demo | ||
- name: Build and publish demo docker image | ||
if: github.ref == 'refs/heads/master' | ||
uses: elgohr/Publish-Docker-Github-Action@master | ||
with: | ||
name: demo-storefrontcloud-io/vue-storefront-api:${{ github.sha }} | ||
registry: registry.storefrontcloud.io | ||
username: ${{ secrets.CLOUD_USERNAME }} | ||
password: ${{ secrets.CLOUD_PASSWORD }} | ||
dockerfile: dev/docker/Dockerfile | ||
buildoptions: "--compress" | ||
|
||
# Build for test | ||
- name: Build and publish test docker image | ||
if: github.ref == 'refs/heads/develop' | ||
uses: elgohr/Publish-Docker-Github-Action@master | ||
with: | ||
name: test-storefrontcloud-io/vue-storefront-api:${{ github.sha }} | ||
registry: registry.storefrontcloud.io | ||
username: ${{ secrets.CLOUD_USERNAME }} | ||
password: ${{ secrets.CLOUD_PASSWORD }} | ||
dockerfile: dev/docker/Dockerfile | ||
buildoptions: "--compress" | ||
|
||
deploy-demo: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: chrnorm/deployment-action@releases/v1 | ||
if: github.ref == 'refs/heads/master' | ||
name: Create GitHub deployment for demo | ||
id: deployment | ||
with: | ||
token: "${{ github.token }}" | ||
target_url: https://demo.europe-west1.gcp.storefrontcloud.io/api/ | ||
environment: production | ||
initial_status: in_progress | ||
# Deploy on demo | ||
- name: Deploy on demo.europe-west1.gcp.storefrontcloud.io | ||
if: github.ref == 'refs/heads/master' | ||
run: | | ||
if curl -s -H 'X-User-Id: ${{ secrets.CLOUD_USERNAME }}' -H 'X-Api-Key: ${{ secrets.CLOUD_PASSWORD }}' -H 'Content-Type: application/json' -X POST -d ' | ||
{ | ||
"code":"demo", | ||
"region":"europe-west1.gcp", | ||
"apiContainerVersion":"${{ github.sha }}" | ||
}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then | ||
echo "Instance updated" | ||
else | ||
echo "Something went wrong during the update process..." | ||
exit 1 | ||
fi | ||
# Return status | ||
- name: Update deployment status (success) | ||
if: success() | ||
uses: chrnorm/deployment-status@releases/v1 | ||
with: | ||
token: "${{ github.token }}" | ||
target_url: https://demo.europe-west1.gcp.storefrontcloud.io | ||
state: "success" | ||
description: Congratulations! The deploy is done. | ||
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | ||
|
||
- name: Update deployment status (failure) | ||
if: failure() | ||
uses: chrnorm/deployment-status@releases/v1 | ||
with: | ||
token: "${{ github.token }}" | ||
target_url: https://demo.europe-west1-southeast1.gcp.storefrontcloud.io | ||
description: Unfortunately, the instance hasn't been updated. | ||
state: "failure" | ||
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | ||
|
||
deploy-test: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: chrnorm/deployment-action@releases/v1 | ||
if: github.ref == 'refs/heads/develop' | ||
name: Create GitHub deployment for test | ||
id: deployment | ||
with: | ||
token: "${{ github.token }}" | ||
target_url: https://test.europe-west1.gcp.storefrontcloud.io/api/ | ||
environment: demo | ||
initial_status: in_progress | ||
# Deploy on demo | ||
- name: Deploy on test.europe-west1.gcp.storefrontcloud.io | ||
if: github.ref == 'refs/heads/develop' | ||
run: | | ||
if curl -s -H 'X-User-Id: ${{ secrets.CLOUD_USERNAME }}' -H 'X-Api-Key: ${{ secrets.CLOUD_PASSWORD }}' -H 'Content-Type: application/json' -X POST -d ' | ||
{ | ||
"code":"test", | ||
"region":"europe-west1.gcp", | ||
"apiContainerVersion":"${{ github.sha }}" | ||
}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then | ||
echo "Instance updated" | ||
else | ||
echo "Something went wrong during the update process..." | ||
exit 1 | ||
fi | ||
# Return status | ||
- name: Update deployment status (success) | ||
if: success() | ||
uses: chrnorm/deployment-status@releases/v1 | ||
with: | ||
token: "${{ github.token }}" | ||
target_url: https://test.europe-west1.gcp.storefrontcloud.io | ||
state: "success" | ||
description: Congratulations! The deploy is done. | ||
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | ||
|
||
- name: Update deployment status (failure) | ||
if: failure() | ||
uses: chrnorm/deployment-status@releases/v1 | ||
with: | ||
token: "${{ github.token }}" | ||
target_url: https://test.europe-west1-southeast1.gcp.storefrontcloud.io | ||
description: Unfortunately, the instance hasn't been updated. | ||
state: "failure" | ||
deployment_id: ${{ steps.deployment.outputs.deployment_id }} |