Skip to content

Commit 7d57b80

Browse files
authored
Create build-and-deploy.yml
1 parent f812bab commit 7d57b80

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build and Deploy DevOps Lab 9
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
env:
10+
APP_NAME: devopslab9
11+
12+
jobs:
13+
build:
14+
name: Build and Upload Artifact
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Generate artifact
22+
run: |
23+
echo "" >> index.html
24+
25+
- name: Upload artifact
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: ${{ env.APP_NAME }}
29+
path: ./
30+
31+
deploy_dev:
32+
name: Deploy to Development
33+
runs-on: ubuntu-latest
34+
needs: build
35+
environment:
36+
name: development
37+
url: https://dev.${{ env.APP_NAME }}.com
38+
39+
steps:
40+
- name: Download artifact
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: ${{ env.APP_NAME }}
44+
45+
- name: Simulate development Deployment
46+
run: |
47+
echo "Simulating Deploying to DEVELOPMENT via SSH: https://dev.${{ env.APP_NAME }}.com"
48+
cat index.html
49+
50+
deploy_staging:
51+
name: Promote to Staging
52+
runs-on: ubuntu-latest
53+
needs: deploy_dev
54+
environment:
55+
name: staging
56+
url: https://staging.${{ env.APP_NAME }}.com
57+
58+
steps:
59+
- name: Download artifact
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: ${{ env.APP_NAME }}
63+
64+
- name: Simulate staging Deployment
65+
run: |
66+
echo "Simulating Deploying to STAGING via SSH: https://staging.${{ env.APP_NAME }}.com"
67+
cat index.html
68+
69+
deploy_prod:
70+
name: Promote to Production
71+
runs-on: ubuntu-latest
72+
needs: deploy_staging
73+
environment:
74+
name: production
75+
url: https://${{ env.APP_NAME }}.com
76+
77+
steps:
78+
- name: Download artifact
79+
uses: actions/download-artifact@v4
80+
with:
81+
name: ${{ env.APP_NAME }}
82+
83+
- name: Simulate production Deployment
84+
run: |
85+
echo "Simulating Deploying to PRODUCTION via SSH: https://${{ env.APP_NAME }}.com"
86+
cat index.html

0 commit comments

Comments
 (0)