-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (71 loc) · 2.7 KB
/
deploy-application.yml
File metadata and controls
78 lines (71 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# This workflow deploys the application to a specified environment
name: Deploy application
# Controls when the action will run. Triggers the workflow on release publish events
on:
workflow_dispatch:
inputs:
destinationEnvironment:
description: 'The target environment'
required: true
type: choice
options:
- "staging"
- "production"
sourceBranch:
description: 'The source branch/commit'
required: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
url: ${{ steps.configure.outputs.url }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Configure deployment variables
- name: Configure deployment
id: configure
run: |
if [ "${{ inputs.destinationEnvironment }}" = "production" ]; then
echo "DESTINATION_REPO=${{ secrets.DESTINATION_REPO_PROD }}" >> $GITHUB_ENV
echo "url=https://tech.frocentric.io" >> $GITHUB_OUTPUT
else
echo "DESTINATION_REPO=${{ secrets.DESTINATION_REPO_STAGE }}" >> $GITHUB_ENV
echo "url=https://tech.staging.frocentric.io" >> $GITHUB_OUTPUT
fi
shell: bash
# Deploys specific branch/commit to target environment
- name: Deploy to target
uses: wei/git-sync@v3
env:
DESTINATION_BRANCH: ${{ 'refs/heads/main' }}
SOURCE_BRANCH: ${{ inputs.sourceBranch }}
SOURCE_REPO: ${{ 'frocentric/wordpress' }}
with:
# GitHub repo slug or full clone url
source_repo: ${SOURCE_REPO}
# Branch name to sync from
source_branch: ${SOURCE_BRANCH}
# GitHub repo slug or full clone url
destination_repo: ${DESTINATION_REPO}
# Branch name to sync to
destination_branch: ${DESTINATION_BRANCH}
# SSH key used to authenticate with git clone urls provided (optional if public or https clone url with authentication)
destination_ssh_private_key: ${{ secrets.SSH_DESTINATION_PRIVATE_KEY }}
check:
needs: [ deploy ]
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Sets the Node version
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Check site
uses: jtalk/url-health-check-action@v4
with:
url: ${{ needs.deploy.outputs.url }}