Feat/tax certificate #705
Workflow file for this run
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: PR Linter and Typescript check | |
on: | |
pull_request: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Run Eslint Checks | |
uses: './.github/actions/eslint' | |
typescript: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Run TS Checks | |
uses: './.github/actions/typescript' | |
get-commit-message: | |
runs-on: ubuntu-latest | |
needs: [typescript, lint] | |
outputs: | |
head-commit-message: ${{ steps.get_head_commit_message.outputs.headCommitMsg }} | |
steps: | |
- name: Get repo | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Get Head Commit Message | |
id: get_head_commit_message | |
run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" | |
build-and-publish-image: | |
runs-on: ubuntu-latest | |
needs: get-commit-message | |
if: contains(needs.get-commit-message.outputs.head-commit-message, 'deploy') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Determine Port | |
id: get_port | |
run: | | |
message=$(echo "${{ needs.get-commit-message.outputs.head-commit-message }}") | |
if [[ $message =~ deploy\(([0-9]+)\): ]]; then | |
tag="${BASH_REMATCH[1]}" | |
echo "PORT=$tag" >> $GITHUB_ENV | |
else | |
tag="" | |
fi | |
- name: Build and publish | |
run: | | |
port="${{ env.PORT }}" | |
echo ${{ secrets.GH_PAT }} | docker login ghcr.io -u awqsomee --password-stdin | |
docker build . --tag ghcr.io/awqsomee/mospolytech-lk-ghcr:feat$port | |
docker push ghcr.io/awqsomee/mospolytech-lk-ghcr:feat$port | |
update-server-containers: | |
runs-on: ubuntu-latest | |
needs: [get-commit-message, build-and-publish-image] | |
if: contains(needs.get-commit-message.outputs.head-commit-message, 'deploy') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install OpenVPN | |
run: | | |
sudo apt-get update | |
sudo apt-get --assume-yes --no-install-recommends install openvpn | |
- name: Setup VPN config | |
run: | | |
echo "${{ secrets.SECRET_USERNAME_PASSWORD }}" > secret.txt | |
echo "${{ secrets.CONFIG }}" > config.ovpn | |
- name: Connect VPN | |
run: sudo openvpn --config "config.ovpn" --log "vpn.log" --daemon | |
- name: Wait for a VPN connection | |
timeout-minutes: 1 | |
run: until ping -c1 ${{ secrets.TEST_HOST_IP }}; do sleep 2; done | |
- name: 'Run deploy on server' | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.TEST_HOST_IP }} | |
username: ${{ secrets.TEST_SERVER_USERNAME }} | |
password: ${{ secrets.TEST_SERVER_PASSWORD }} | |
script: | | |
cd client-app/LK | |
echo ${{ secrets.TEST_SERVER_PASSWORD }} | sudo -S docker compose -p web pull | |
echo ${{ secrets.TEST_SERVER_PASSWORD }} | sudo -S docker compose -p web up -d | |
- name: Kill VPN connection | |
if: always() | |
run: | | |
sudo chmod 777 vpn.log | |
sudo killall openvpn | |
- name: Upload VPN logs | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: VPN logs | |
path: vpn.log |