Merge pull request #816 from HSLdevcom/dev #40
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 and test production | |
on: | |
push: | |
branches: | |
- production | |
jobs: | |
deploy-production: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: production | |
- name: Build UI and publish Docker image | |
uses: elgohr/Publish-Docker-Github-Action@master | |
with: | |
name: hsldevcom/transitlog-ui | |
username: ${{ secrets.TRANSITLOG_DOCKERHUB_USER }} | |
password: ${{ secrets.TRANSITLOG_DOCKERHUB_TOKEN }} | |
buildargs: BUILD_ENV=production | |
tags: production | |
- name: Checkout server | |
uses: actions/checkout@v2 | |
with: | |
repository: HSLdevcom/transitlog-server | |
ref: production | |
- name: Build Server and publish Docker image | |
uses: elgohr/Publish-Docker-Github-Action@master | |
with: | |
name: hsldevcom/transitlog-server | |
username: ${{ secrets.TRANSITLOG_DOCKERHUB_USER }} | |
password: ${{ secrets.TRANSITLOG_DOCKERHUB_TOKEN }} | |
tags: production | |
- name: Deploy with Gitlab CI | |
run: curl -X POST -F token=${{ secrets.GITLAB_PROD_TRIGGER_TOKEN }} -F ref=master https://gitlab.hsl.fi/api/v4/projects/233/trigger/pipeline | |
- name: Notify of deployment | |
uses: 8398a7/action-slack@v2 | |
if: always() | |
with: | |
status: ${{ job.status }} | |
text: Reittiloki PROD deployment status | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
test-production: | |
needs: deploy-production | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: "14" | |
- uses: actions/checkout@v2 | |
with: | |
ref: production | |
- name: Sleep for 5 minutes | |
uses: jakejarvis/wait-action@master | |
with: | |
time: "5m" # Wait until all servers are restarted | |
- name: Cypress tests | |
uses: cypress-io/github-action@v2 | |
# with: | |
# record: true # Only production records to Cypress.io | |
env: | |
CYPRESS_BASE_URL: https://reittiloki.hsl.fi | |
CYPRESS_CLIENT_ID: ${{ secrets.CYPRESS_CLIENT_ID }} | |
CYPRESS_CLIENT_SECRET: ${{ secrets.CYPRESS_CLIENT_SECRET }} | |
CYPRESS_HSL_TESTING_HSLID_USERNAME: ${{ secrets.CYPRESS_HSL_TESTING_HSLID_USERNAME }} | |
CYPRESS_HSL_TESTING_HSLID_PASSWORD: ${{ secrets.CYPRESS_HSL_TESTING_HSLID_PASSWORD }} | |
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
- name: Upload screenshot artifacts | |
uses: actions/upload-artifact@v1 | |
if: failure() | |
with: | |
name: cypress-screenshots | |
path: cypress/screenshots | |
- name: Upload video artifacts | |
uses: actions/upload-artifact@v1 | |
if: failure() | |
with: | |
name: cypress-videos | |
path: cypress/videos | |
- name: Notify of tests | |
uses: 8398a7/action-slack@v2 | |
if: failure() | |
with: | |
status: ${{ job.status }} | |
text: Reittiloki PROD E2E test status | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |