Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions .github/workflows/deploy-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ jobs:
needs: start-notification
runs-on: ubuntu-latest
steps:
- name: Configure host authenticity
- &ssh-host-auth
name: Configure host authenticity
run: |
mkdir -p ~/.ssh/ && chmod 700 ~/.ssh/
touch ~/.ssh/known_hosts && chmod 600 ~/.ssh/known_hosts
Expand All @@ -106,8 +107,8 @@ jobs:
cp ~/.env-production dashboard-production/.env &&
cd dashboard-production &&
git checkout ${GITHUB_SHA} &&
docker compose -f docker-compose-next.yml pull &&
docker compose -f docker-compose-next.yml up -d
docker compose -f docker-compose-next.yml pull --policy=always &&
docker compose -f docker-compose-next.yml up -d --remove-orphans
"
env:
SSH_USER: ${{ secrets.STAGING_USER }}
Expand All @@ -129,3 +130,24 @@ jobs:
uses: Ilshidur/action-discord@master
with:
args: "Production Dashboard deployment failed with tag `${{ github.event.inputs.tag }}`"

cleanup:
needs: deploy-production
runs-on: ubuntu-latest
steps:
- *ssh-host-auth
- name: Prune docker artifacts on remote
env:
SSH_USER: ${{ secrets.STAGING_USER }}
SSH_HOST: ${{ secrets.STAGING_HOST }}
SSH_KEY: ${{ secrets.STAGING_KEY }}
run: |
eval $(ssh-agent -s)
echo "$SSH_KEY" | ssh-add - >/dev/null
ssh "${SSH_USER}@${SSH_HOST}" <<<'EOF'
set -eu
docker image prune -fa --filter "until=48h"
docker builder prune -f --filter "until=48h"
docker volume ls --filter dangling=true --format "::warning::volume {{.Name}} is dangling"
docker container ls --filter status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"
EOF
30 changes: 26 additions & 4 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ jobs:
needs: check-migrations
runs-on: ubuntu-latest
steps:
- name: Configure staging host authenticity
- &ssh-host-auth
name: Configure staging host authenticity
run: |
mkdir -p ~/.ssh/ && chmod 700 ~/.ssh/
touch ~/.ssh/known_hosts && chmod 600 ~/.ssh/known_hosts
echo "$SSH_HOSTKEY" > ~/.ssh/known_hosts
env:
SSH_HOSTKEY: ${{ secrets.STAGING_HOSTKEY }}

- name: Deploy to staging
run: |
eval $(ssh-agent -s)
Expand All @@ -67,15 +68,36 @@ jobs:
cp ~/.env-staging dashboard-staging/.env &&
cd dashboard-staging &&
git checkout ${GITHUB_SHA} &&
docker compose down &&
docker compose pull --ignore-buildable --policy=always &&
docker compose build --no-cache &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with the policy of always pulling, isn´t it safer to build with no-cache here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

docker compose up -d
docker compose up -d --remove-orphans
"
env:
SSH_USER: ${{ secrets.STAGING_USER }}
SSH_HOST: ${{ secrets.STAGING_HOST }}
SSH_KEY: ${{ secrets.STAGING_KEY }}

cleanup:
needs: deploy-staging
runs-on: ubuntu-latest
steps:
- *ssh-host-auth
- name: Prune docker artifacts on remote
env:
SSH_USER: ${{ secrets.STAGING_USER }}
SSH_HOST: ${{ secrets.STAGING_HOST }}
SSH_KEY: ${{ secrets.STAGING_KEY }}
run: |
eval $(ssh-agent -s)
echo "$SSH_KEY" | ssh-add - >/dev/null
ssh "${SSH_USER}@${SSH_HOST}" <<<'EOF'
set -eu
docker image prune -fa --filter "until=48h"
docker builder prune -f --filter "until=48h"
docker volume ls --filter dangling=true --format "::warning::volume {{.Name}} is dangling"
docker container ls --filter status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"
EOF

e2e-tests:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/staging-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,23 @@ jobs:
git fetch
git checkout ${{ github.event.inputs.GIT_BRANCH }}
cd ..
docker compose -f docker-compose-all.yaml --profile=self-hosted pull --ignore-buildable
docker compose -f docker-compose-all.yaml --profile=self-hosted build
docker compose -f docker-compose-all.yaml --profile=self-hosted up -d --remove-orphans

cleanup:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Prune docker artifacts on remote
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DB_SSH_HOST }}
username: ${{ secrets.DB_SSH_USER }}
key: ${{ secrets.DB_SSH_KEY }}
script: |
set -eu
docker image prune -fa --filter "until=48h"
docker builder prune -f --filter "until=48h"
docker volume ls --filter dangling=true --format "::warning::volume {{.Name}} is dangling"
docker container ls --filter status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"
Loading