Deploy #1
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: | |
workflow_dispatch: | |
workflow_run: | |
workflows: [Release] | |
types: | |
- completed | |
jobs: | |
notify-start: | |
runs-on: ubuntu-latest | |
# Only continue if the workflow run was successful | |
# Subsequent jobs will not run if this job fails, | |
# because of the `needs` parameters in the other jobs. | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Discord Webhook - Notify Start Deploy | |
uses: tsickert/[email protected] | |
continue-on-error: true | |
with: | |
username: "Mirasaki Development CI/CD" | |
avatar-url: "https://mirasaki.dev/logo.png" | |
webhook-url: ${{ secrets.DEPLOYMENT_WEBHOOK_URL }} | |
embed-author-name: "Continuous Deployment by Mirasaki Development" | |
embed-author-url: "https://mirasaki.dev" | |
embed-author-icon-url: "https://mirasaki.dev/logo.png" | |
embed-color: 14228765 | |
embed-title: "⬇️ [Demo] DayZ Community Template" | |
embed-description: "⌛ Deploying **`@${{ github.repository }}`**...\n📤 Service is now temporarily unavailable." | |
deploy: | |
strategy: # Only run one deploy job at a time | |
max-parallel: 1 | |
permissions: | |
# The "id-token: write" permission is required or Machine ID will not be | |
# able to authenticate with the cluster. | |
id-token: write | |
contents: read | |
name: deploy | |
needs: notify-start | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Fetch Teleport binaries | |
uses: teleport-actions/setup@v1 | |
with: | |
version: 14.2.3 | |
- name: Fetch credentials using Machine ID | |
id: auth | |
uses: teleport-actions/auth@v2 | |
with: | |
proxy: teleport.mirasaki.dev:443 | |
token: deploy-bot | |
certificate-ttl: 1h | |
anonymous-telemetry: 1 | |
- name: Deploy to Production | |
run: | | |
tsh ssh mirasaki-development@mirasaki-development << 'ENDSSH' | |
cd /var/www/mirasaki/dayz-community-template | |
git pull origin main | |
docker compose build --no-cache --pull --quiet | |
docker compose down | |
docker compose up -d | |
exit | |
ENDSSH | |
notify-finish: | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Discord Webhook - Notify Finish Deploy | |
uses: tsickert/[email protected] | |
with: | |
username: "Mirasaki Development CI/CD" | |
avatar-url: "https://mirasaki.dev/logo.png" | |
webhook-url: ${{ secrets.DEPLOYMENT_WEBHOOK_URL }} | |
filename: "CHANGELOG.md" | |
embed-author-name: "Continuous Deployment by Mirasaki Development" | |
embed-author-url: "https://mirasaki.dev" | |
embed-author-icon-url: "https://mirasaki.dev/logo.png" | |
embed-color: 9559538 | |
embed-title: "⬆️ [Demo] DayZ Community Template" | |
embed-description: "✅ Finished deploying **`@${{ github.repository }}`**\n📥 [Service](https://template-1.mirasaki.dev/) is back online" |