|
| 1 | +# we stop the application by uploading an app_offline.htm file |
| 2 | +# then we wait for a few seconds to let IIS unload the application and release file locks |
| 3 | + |
| 4 | +# https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/app-offline?view=aspnetcore-10.0 |
| 5 | + |
| 6 | +name: staging deploy |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [master] |
| 11 | + |
| 12 | +jobs: |
| 13 | + deploy: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: setup .NET |
| 21 | + uses: actions/setup-dotnet@v4 |
| 22 | + with: |
| 23 | + dotnet-version: 9.0.x |
| 24 | + |
| 25 | + - name: publish application |
| 26 | + run: | |
| 27 | + dotnet publish Source/HttpsRichardy.Federation.WebApi \ |
| 28 | + -c Release \ |
| 29 | + -r win-x64 \ |
| 30 | + -o ./publish |
| 31 | +
|
| 32 | + - name: remove unwanted config files |
| 33 | + run: | |
| 34 | + rm -f ./publish/appsettings.json |
| 35 | + rm -f ./publish/appsettings.Development.json |
| 36 | + rm -f ./publish/web.config |
| 37 | +
|
| 38 | + - name: put application offline |
| 39 | + run: echo "offline" > app_offline.htm |
| 40 | + |
| 41 | + - name: upload app_offline.htm |
| 42 | + run: | |
| 43 | + sudo apt-get install -y lftp |
| 44 | + lftp -u ${{ secrets.FTP_USER }},${{ secrets.FTP_PASSWORD }} vinder-federation.somee.com <<EOF |
| 45 | + cd /www.vinder-federation.somee.com/ |
| 46 | + put app_offline.htm |
| 47 | + quit |
| 48 | + EOF |
| 49 | +
|
| 50 | + - name: wait for IIS |
| 51 | + run: sleep 10 |
| 52 | + |
| 53 | + - name: deploy publish via FTP (no delete) |
| 54 | + run: | |
| 55 | + lftp -u ${{ secrets.FTP_USER }},${{ secrets.FTP_PASSWORD }} vinder-federation.somee.com <<EOF |
| 56 | + set ftp:ssl-allow no |
| 57 | + set ftp:chmod false |
| 58 | + set mirror:set-permissions false |
| 59 | + set mirror:use-pget-n false |
| 60 | +
|
| 61 | + mirror -R ./publish /www.vinder-federation.somee.com \ |
| 62 | + --only-newer \ |
| 63 | + --verbose |
| 64 | +
|
| 65 | + quit |
| 66 | + EOF |
| 67 | +
|
| 68 | + - name: remove app_offline.htm |
| 69 | + run: | |
| 70 | + lftp -u ${{ secrets.FTP_USER }},${{ secrets.FTP_PASSWORD }} vinder-federation.somee.com <<EOF |
| 71 | + cd /www.vinder-federation.somee.com/ |
| 72 | + rm app_offline.htm |
| 73 | + quit |
| 74 | + EOF |
0 commit comments