Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…oup_8 into main
  • Loading branch information
aymanazahar32 committed Apr 16, 2024
2 parents 2f02551 + d4a26a4 commit 76bd747
Show file tree
Hide file tree
Showing 42 changed files with 21,612 additions and 21,588 deletions.
146 changes: 73 additions & 73 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
# Derived from an example provided by https://blog.benoitblanchon.fr/github-action-run-ssh-commands/
# https://github.blog/2015-06-16-read-only-deploy-keys/
#
#
#
#
#
name: Deploy
on: [push]
jobs:
deploy:
name: "Deploy to server"
runs-on: ubuntu-latest
steps:
- name: configure SSH
run: |
# These are very useful for debugging
echo "Repository = ${{ github.repository }}"
echo "github url = ${{ github.server_url }}"
echo "Owner = ${{ github.repository_owner }}"
echo "Repository name = ${{ github.event.repository.name }}"
echo "Service name = ${{ vars.service_name }}"
echo "http port = ${{ vars.http_port }}"
echo "websocket port = ${{ vars.websocket_port }}"
echo "version = $${ github.sha }}"
# On to the work at hand.
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/production.key
chmod 600 ~/.ssh/production.key
cat >>~/.ssh/config <<END
Host production
HostName ${{ secrets.SSH_HOST }}
User ${{ secrets.SSH_USER }}
IdentityFile ~/.ssh/production.key
StrictHostKeyChecking no
END
- name: get source code and compile
run: |
echo "deleting the directory ${{ github.event.repository.name }} "
ssh production "rm -rf ${{ github.event.repository.name }}"
echo "cloning ${{ github.server_url }}/${{ github.repository }}"
ssh production "git clone ${{ github.server_url }}/${{ github.repository }}"
ssh production "cd ${{ github.event.repository.name }};mvn clean compile package"
- name: create systemd unit file
run: |
# without enable-linger, you must be logged in. So, we enable it.
ssh production "loginctl enable-linger"
ssh production "mkdir --parents .config/systemd/user"
ssh production "rm -f .config/systemd/user/${{ vars.service_name }}.service"
ssh production 'echo "[Unit]" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Description=${{ vars.service_name }}" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "[Service]" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Type=simple" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Restart=always" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "RestartSec=5" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Environment=VERSION=\"${{ github.sha }}\"" >>.config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Environment=WEBSOCKET_PORT=${{ vars.websocket_port }}" >>.config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Environment=HTTP_PORT=${{ vars.http_port }}" >>.config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "ExecStart=mvn exec:java -Dexec.mainClass=uta.cse3310.App" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "WorkingDirectory=$PWD/${{ github.event.repository.name }}" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "[Install]" >>.config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "WantedBy=default.target" >>.config/systemd/user/${{ vars.service_name }}.service'
- name: systemd reload
run: |
ssh production "systemctl --user daemon-reload"
- name: restart daemon
run: |
ssh production "systemctl --user enable ${{ vars.service_name }}"
ssh production "systemctl --user restart ${{ vars.service_name }}"
ssh production "systemctl --user status ${{ vars.service_name }}"
# Derived from an example provided by https://blog.benoitblanchon.fr/github-action-run-ssh-commands/
# https://github.blog/2015-06-16-read-only-deploy-keys/
#
#
#
#
#
name: Deploy
on: [push]
jobs:
deploy:
name: "Deploy to server"
runs-on: ubuntu-latest
steps:
- name: configure SSH
run: |
# These are very useful for debugging
echo "Repository = ${{ github.repository }}"
echo "github url = ${{ github.server_url }}"
echo "Owner = ${{ github.repository_owner }}"
echo "Repository name = ${{ github.event.repository.name }}"
echo "Service name = ${{ vars.service_name }}"
echo "http port = ${{ vars.http_port }}"
echo "websocket port = ${{ vars.websocket_port }}"
echo "version = $${ github.sha }}"
# On to the work at hand.
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/production.key
chmod 600 ~/.ssh/production.key
cat >>~/.ssh/config <<END
Host production
HostName ${{ secrets.SSH_HOST }}
User ${{ secrets.SSH_USER }}
IdentityFile ~/.ssh/production.key
StrictHostKeyChecking no
END
- name: get source code and compile
run: |
echo "deleting the directory ${{ github.event.repository.name }} "
ssh production "rm -rf ${{ github.event.repository.name }}"
echo "cloning ${{ github.server_url }}/${{ github.repository }}"
ssh production "git clone ${{ github.server_url }}/${{ github.repository }}"
ssh production "cd ${{ github.event.repository.name }};mvn clean compile package"
- name: create systemd unit file
run: |
# without enable-linger, you must be logged in. So, we enable it.
ssh production "loginctl enable-linger"
ssh production "mkdir --parents .config/systemd/user"
ssh production "rm -f .config/systemd/user/${{ vars.service_name }}.service"
ssh production 'echo "[Unit]" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Description=${{ vars.service_name }}" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "[Service]" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Type=simple" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Restart=always" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "RestartSec=5" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Environment=VERSION=\"${{ github.sha }}\"" >>.config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Environment=WEBSOCKET_PORT=${{ vars.websocket_port }}" >>.config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "Environment=HTTP_PORT=${{ vars.http_port }}" >>.config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "ExecStart=mvn exec:java -Dexec.mainClass=uta.cse3310.App" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "WorkingDirectory=$PWD/${{ github.event.repository.name }}" >> .config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "[Install]" >>.config/systemd/user/${{ vars.service_name }}.service'
ssh production 'echo "WantedBy=default.target" >>.config/systemd/user/${{ vars.service_name }}.service'
- name: systemd reload
run: |
ssh production "systemctl --user daemon-reload"
- name: restart daemon
run: |
ssh production "systemctl --user enable ${{ vars.service_name }}"
ssh production "systemctl --user restart ${{ vars.service_name }}"
ssh production "systemctl --user status ${{ vars.service_name }}"
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# TicTacToe

```bash
% export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.18.0.9-0.3.ea.el8.x86_64
% mvn clean
% mvn compile
% mvn package
% mvn exec:java -Dexec.mainClass=uta.cse3310.App


# TicTacToe

```bash
% export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.18.0.9-0.3.ea.el8.x86_64
% mvn clean
% mvn compile
% mvn package
% mvn exec:java -Dexec.mainClass=uta.cse3310.App


Loading

0 comments on commit 76bd747

Please sign in to comment.