Fix deployment script #3
Workflow file for this run
This file contains hidden or 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: | |
| push: | |
| tags: | |
| - '**' | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| continue-on-error: false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: "8.4" | |
| - name: "Extract production files" | |
| env: | |
| DEPLOY_KEY: ${{ secrets.DEPLOYMENT_KEY }} | |
| run: | | |
| # Remove a possibly existing extraction folder | |
| rm -rf extract | |
| # Now that we are sure it's not there, create an empty extraction folder | |
| mkdir extract | |
| # Create an archive from the repository based on the given tag | |
| # and extract that into the just created extraction folder. | |
| git archive --prefix="./" --format=tar ${{ github.event.pull_request.head.sha || github.sha }} .| tar xv -C extract/ | |
| - name: "Cache calendar vendor dir" | |
| uses: "actions/cache@v4" | |
| with: | |
| path: ${{ github.workspace }}/extract/vendor | |
| key: "vendor-build-${{ hashFiles('*/composer.lock') }}" | |
| - uses: "ramsey/composer-install@v3" | |
| with: | |
| dependency-versions: "locked" | |
| working-directory: extract | |
| composer-options: --no-dev --optimize-autoloader --classmap-authoritative | |
| - name: "Archive build" | |
| id: archive-build | |
| run: | | |
| buildfile="build-${{ github.event.pull_request.head.sha || github.sha }}.tar.gz" | |
| tar --exclude-vcs -czf $buildfile -C extract/ . | |
| - name: Configure SSH | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.DEPLOY_KEY }} | |
| - name: "Deploy" | |
| run: | | |
| ssh-keyscan -t rsa ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts | |
| scp -r extract/* ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/${{ secrets.REPO_PATH }}/${{ github.event.pull_request.head.sha || github.sha }} | |
| ssh ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} "cd ${{ secrets.REPO_PATH }} && cp current/config/callingallpapers.ini ${{ github.event.pull_request.head.sha || github.sha }}/config/callingallpapers.ini && rm current && ln -sr ${{ github.event.pull_request.head.sha || github.sha }} current" | |