Merge pull request #10 from fi-ksi/main #70
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: deploy-prod | |
on: | |
push: | |
branches: | |
- 'prod' | |
jobs: | |
deploy-prod: | |
runs-on: ubuntu-latest | |
steps: | |
- run: mkdir src | |
name: prepare env | |
- uses: actions/checkout@v2 | |
name: checkout src | |
with: | |
fetch-depth: 100 | |
path: 'src' | |
- name: prepare dist tar | |
shell: bash | |
run: | | |
cd src && | |
npm install && | |
npm run build.prod && | |
cd dist/web-frontend-angular/cs/ && | |
cp -r ../cgi-bin cgi-bin && | |
tar -cvf ../../dist.tar * | |
- name: create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: temp-${{ github.sha }} | |
release_name: temp-${{ github.sha }} | |
body: "Automatic temporary release from the CI/CD" | |
draft: false | |
prerelease: true | |
- name: upload tar to the release | |
id: upload_tar | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: src/dist/dist.tar | |
asset_name: build.tar | |
asset_content_type: application/x-tar | |
- name: notify backend server | |
shell: bash | |
run: | | |
echo "Asset URL: ${{ steps.upload_tar.outputs.browser_download_url }}" | |
status="$(curl -X POST -u '${{ secrets.PROD_DEPLOY_USER }}:${{ secrets.PROD_DEPLOY_PASSWORD }}' -d '${{ steps.upload_tar.outputs.browser_download_url }}' '${{ secrets.PROD_DEPLOY_URL }}')" | |
if [ "$status" = "OK" ]; then | |
echo "Notified OK!" | |
else | |
echo "Notification error" | |
echo "$status" | |
false | |
fi | |
- name: delete temporary release | |
if: always() | |
uses: esoadamo/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
release-name: temp-${{ github.sha }} |