|
| 1 | +name: Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'master' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build & Publish 🚀 |
| 12 | + runs-on: self-hosted |
| 13 | + env: |
| 14 | + INPUTPATH: asciidocs |
| 15 | + OUTPUTPATH: dist |
| 16 | + SLIDES: true |
| 17 | + BRANCH: gh-pages |
| 18 | + steps: |
| 19 | + - name: Checkout repo |
| 20 | + uses: actions/checkout@v4 |
| 21 | + - name: Build |
| 22 | + uses: quirinecker/asciidoctor-convert-action@main |
| 23 | + with: |
| 24 | + slides: ${{ env.SLIDES }} |
| 25 | + inputPath: ${{ env.INPUTPATH }} |
| 26 | + outputPath: ${{ env.OUTPUTPATH }} |
| 27 | + - name: Deploy to GitHub Pages |
| 28 | + uses: JamesIves/github-pages-deploy-action@releases/v4 |
| 29 | + with: |
| 30 | + TOKEN: ${{ github.TOKEN }} |
| 31 | + BRANCH: ${{ env.BRANCH }} |
| 32 | + FOLDER: ${{ env.OUTPUTPATH }} |
| 33 | + bump: |
| 34 | + name: Get And Bump SemVer 👊 |
| 35 | + runs-on: self-hosted |
| 36 | + needs: [build] |
| 37 | + steps: |
| 38 | + - name: Checkout repo |
| 39 | + uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + fetch-depth: '0' |
| 42 | + - name: Bump version and push tag |
| 43 | + uses: anothrNick/github-tag-action@master |
| 44 | + env: |
| 45 | + GITHUB_TOKEN: ${{ github.TOKEN }} |
| 46 | + RELEASE_BRANCHES: master |
| 47 | + DEFAULT_BUMP: patch |
| 48 | + WITH_V: false |
| 49 | + docker-build: |
| 50 | + name: Build Docker Image 🐋 |
| 51 | + runs-on: self-hosted |
| 52 | + needs: [bump] |
| 53 | + steps: |
| 54 | + - name: Checkout repo |
| 55 | + uses: actions/checkout@v4 |
| 56 | + - name: Checkout site |
| 57 | + uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + ref: gh-pages |
| 60 | + path: site |
| 61 | + - name: Touch .env file |
| 62 | + run: touch site/.env |
| 63 | + - name: Fill .env file |
| 64 | + run: | |
| 65 | + echo NEXT_PUBLIC_PORT=${{ secrets.PORT }} >> site/.env |
| 66 | + echo NEXT_PUBLIC_START_PAGE=${{ secrets.START_PAGE }} >> site/.env |
| 67 | + echo NEXT_PUBLIC_PLANTUML_URL=${{ secrets.PLANTUML_URL }} >> site/.env |
| 68 | + echo NEXT_PUBLIC_SERVER_URL=${{ secrets.SERVER_URL }} >> site/.env |
| 69 | + echo NEXT_PUBLIC_IS_APP_FOLDER=true >> site/.env |
| 70 | + - name: Touch keycloak.json file |
| 71 | + run: touch site/keycloak.json |
| 72 | + - name: Fill keycloak.json file |
| 73 | + run: | |
| 74 | + cat <<EOF >> site/keycloak.json |
| 75 | + ${{ secrets.KEYCLOAK_FILE }} |
| 76 | + EOF |
| 77 | + - name: Setup QEMU |
| 78 | + uses: docker/setup-qemu-action@v3 |
| 79 | + - name: Set up Docker Buildx |
| 80 | + uses: docker/setup-buildx-action@v3 |
| 81 | + |
| 82 | + - name: Login to DockerHub |
| 83 | + uses: docker/login-action@v3 |
| 84 | + with: |
| 85 | + username: ${{ secrets.DOCKER_HUB_USER }} |
| 86 | + password: ${{ secrets.DOCKER_HUB_PASSWORD }} |
| 87 | + - name: Build and push |
| 88 | + uses: docker/build-push-action@v5 |
| 89 | + with: |
| 90 | + context: ./ |
| 91 | + file: ./Dockerfile |
| 92 | + platforms: linux/amd64,linux/arm64/v8 |
| 93 | + push: true |
| 94 | + tags: ${{ secrets.DOCKER_HUB_USER }}/safe-learn:latest |
| 95 | + deploy: |
| 96 | + name: Deployment 💻 |
| 97 | + runs-on: self-hosted |
| 98 | + needs: [docker-build] |
| 99 | + steps: |
| 100 | + - name: Checkout repo |
| 101 | + uses: actions/checkout@v4 |
| 102 | + - name: Install OpenVPN |
| 103 | + run: | |
| 104 | + sudo apt update |
| 105 | + sudo apt install -y openvpn openvpn-systemd-resolved |
| 106 | + - name: Touch OVPN client-config file |
| 107 | + run: touch client.ovpn |
| 108 | + - name: Fill OVPN client-config file |
| 109 | + run: | |
| 110 | + echo "${{ secrets.VPN_OVPN_FILE }}" >> client.ovpn |
| 111 | + - name: Connect to VPN 🔓 |
| 112 | + uses: "kota65535/github-openvpn-connect-action@v3" |
| 113 | + with: |
| 114 | + config_file: client.ovpn |
| 115 | + username: ${{ secrets.VPN_USERNAME }} |
| 116 | + password: ${{ secrets.VPN_PASSWORD }} |
| 117 | + - name: Installing SSH key 🔑 |
| 118 | + uses: UnterrainerInformatik/setup-ssh-action@v1 |
| 119 | + with: |
| 120 | + key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }} |
| 121 | + - name: Create deploy directory 🚧 |
| 122 | + uses: UnterrainerInformatik/ssh-mkdir-action@v1 |
| 123 | + with: |
| 124 | + dir: /app/deploy/${{ secrets.DEPLOY_DIR }} |
| 125 | + user: ${{ secrets.DEPLOY_SSH_USER }} |
| 126 | + host: ${{ secrets.DEPLOY_SERVER }} |
| 127 | + port: ${{ secrets.DEPLOY_SSH_PORT }} |
| 128 | + - name: Create data directory 🚧 |
| 129 | + uses: UnterrainerInformatik/ssh-mkdir-action@v1 |
| 130 | + with: |
| 131 | + dir: /app/data/${{ secrets.DEPLOY_DIR }} |
| 132 | + user: ${{ secrets.DEPLOY_SSH_USER }} |
| 133 | + host: ${{ secrets.DEPLOY_SERVER }} |
| 134 | + port: ${{ secrets.DEPLOY_SSH_PORT }} |
| 135 | + - name: Deploy using SSH 🚛 |
| 136 | + uses: UnterrainerInformatik/ssh-deploy-action@v1 |
| 137 | + with: |
| 138 | + source: ./deploy |
| 139 | + target: /app/deploy/${{ secrets.DEPLOY_DIR }} |
| 140 | + chmod-mask: 777 |
| 141 | + chmod-selector: ./deploy/*.sh |
| 142 | + user: ${{ secrets.DEPLOY_SSH_USER }} |
| 143 | + host: ${{ secrets.DEPLOY_SERVER }} |
| 144 | + port: ${{ secrets.DEPLOY_SSH_PORT }} |
| 145 | + - name: Run using SSH 🏃 |
| 146 | + uses: UnterrainerInformatik/ssh-run-action@v1 |
| 147 | + with: |
| 148 | + dir: /app/deploy/${{ secrets.DEPLOY_DIR }} |
| 149 | + file: up.sh |
| 150 | + user: ${{ secrets.DEPLOY_SSH_USER }} |
| 151 | + host: ${{ secrets.DEPLOY_SERVER }} |
| 152 | + port: ${{ secrets.DEPLOY_SSH_PORT }} |
| 153 | + |
0 commit comments