Merge pull request #3474 from Cryptorubic/id-976 #1150
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
name: Update production server | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
jobs: | |
deploy: | |
name: Deploy on production server | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Read .nvmrc | |
run: echo ::set-output name=NVMRC::$(cat .nvmrc) | |
id: nvm | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '${{ steps.nvm.outputs.NVMRC }}' | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: npm-${{ hashFiles('package-lock.json') }} | |
restore-keys: npm- | |
- name: Set up packages | |
run: yarn --frozen-lockfile | |
- name: Set up sshpass and npm | |
run: | | |
sudo apt-get install sshpass | |
yarn --frozen-lockfile | |
- name: Run build prod | |
run: yarn run build | tee log.txt | |
- name: Create changes file | |
run: node scripts/extracts-chages.js | |
- name: Get all changed assets | |
id: changed-files-yaml | |
uses: tj-actions/changed-files@v37 | |
with: | |
files_yaml: | | |
src: | |
- assets/** | |
- favicon.ico | |
- index.html | |
- manifest.json | |
- name: List all changed files | |
run: | | |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | |
echo "$file" >> files.txt | |
done | |
- name: Show changes | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Changes | |
path: files.txt | |
- name: Upload to storage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Build | |
path: dist/ | |
- name: Get branch names. | |
id: branch-names | |
uses: tj-actions/branch-names@v6 | |
- name: Retreive merge title | |
uses: actions-ecosystem/action-regex-match@v2 | |
id: regex-match | |
with: | |
text: ${{ github.event.head_commit.message }} | |
regex: '.*$' | |
flags: 'm' | |
- name: Notify bot | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: '${{ secrets.deploy_url}}' | |
method: 'POST' | |
customHeaders: '{"Content-Type": "application/json"}' | |
data: '{"targetServer": "production", "initiator": "${{ github.actor }}", "feature": "${{steps.regex-match.outputs.match }}"}' |