Skip to content

Commit

Permalink
updated github workflow to delete old deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ahnaf committed Sep 10, 2024
1 parent a8d3bd7 commit ea66cc2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ on:
- 'README.md'

env:
AZURE_WEBAPP_NAME: bookify
WEBAPP_NAME: bookify
NODE_VERSION: '20.x'

jobs:
cleanup:
runs-on: ubuntu-latest
permissions: write-all

steps:
- name: 🗑️ Delete deployment
uses: strumwolf/delete-deployment-environment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: 'develop'
onlyRemoveDeployments: true

build:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -55,7 +67,7 @@ jobs:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
name: 'develop'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
Expand All @@ -71,3 +83,6 @@ jobs:
run: railway up --service bookify
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

- name: Get the deployment URL
run: echo "url=https://${{ env.WEBAPP_NAME }}-development.up.railway.app" >> $GITHUB_ENV
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ env:
NODE_VERSION: '20.x'

jobs:
cleanup:
runs-on: ubuntu-latest
permissions: write-all

steps:
- name: 🗑️ Delete deployment
uses: strumwolf/delete-deployment-environment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: 'production'
onlyRemoveDeployments: true

build:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -53,7 +65,7 @@ jobs:

deploy:
runs-on: ubuntu-latest
needs: build
needs: build, cleanup
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
Expand All @@ -70,3 +82,6 @@ jobs:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: .

- name: Get the deployment URL
run: echo "url=https://${{ env.AZURE_WEBAPP_NAME }}.azurewebsites.net" >> $GITHUB_ENV

0 comments on commit ea66cc2

Please sign in to comment.