deploy #80
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 | |
on: | |
release: | |
types: [ created ] | |
workflow_run: | |
workflows: [ "build" ] | |
types: [ completed ] | |
branches: [ master ] | |
jobs: | |
deploy-jar: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'release' || github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 17 | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build JAR | |
run: ./gradlew bootJar | |
- name: Copy JAR to Oracle VM | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.ORACLE_HOST }} | |
username: ${{ secrets.ORACLE_USERNAME }} | |
key: ${{ secrets.ORACLE_KEY }} | |
source: "build/libs/*.jar" | |
target: "sofia-supermarkets-api/jars" | |
strip_components: 2 | |
- name: Restart systemd service | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.ORACLE_HOST }} | |
username: ${{ secrets.ORACLE_USERNAME }} | |
key: ${{ secrets.ORACLE_KEY }} | |
script: | | |
chmod 775 sofia-supermarkets-api/jars/*.jar | |
echo "Restarting systemd service" | |
sudo systemctl restart sofia-supermarkets-api | |
sleep 10 | |
echo "Verifying service is active" | |
sudo systemctl is-active sofia-supermarkets-api | |
deploy-proxy: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'release' || github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Publish worker to Cloudflare | |
uses: cloudflare/[email protected] | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
workingDirectory: "proxy" | |
command: deploy |