Deploy to beta manually #63
Workflow file for this run
This file contains 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 to beta manually | |
concurrency: | |
group: deploy-beta | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
jobs: | |
deploy: | |
environment: beta | |
name: Deploy to beta | |
runs-on: ubuntu-22.04 | |
env: | |
REPO_NAME: toby | |
steps: | |
- name: set branch name | |
run: echo "BRANCH_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ env.BRANCH_NAME }} | |
- name: sync with main branch | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
git merge --no-commit --no-ff origin/main | |
- name: set deployment project version | |
run: echo "DEPLOYMENT_PROJECT_VERSION=$(bash ./environment/prod/deployment/scripts/version.sh --long)" >> $GITHUB_ENV | |
- name: set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }} | |
tags: type=raw,value=beta | |
context: git | |
- name: build and push image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./environment/prod/app/Dockerfile | |
build-args: DEPLOYMENT_PROJECT_VERSION_ARG=${{ env.DEPLOYMENT_PROJECT_VERSION }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true | |
tags: ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }}:beta | |
cache-from: type=gha, ref=ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }}-beta-build-cache | |
cache-to: type=gha, ref=ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }}-beta-build-cache, mode=max | |
- name: copy files via ssh | |
uses: appleboy/[email protected] | |
with: | |
timeout: 10s | |
command_timeout: 10m | |
host: ${{ secrets.VPS_OVH_BF7EC892_HOST }} | |
port: ${{ secrets.VPS_OVH_BF7EC892_PORT }} | |
username: ${{ secrets.VPS_OVH_BF7EC892_USERNAME }} | |
key: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY }} | |
passphrase: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY_PASSPHRASE }} | |
source: "./environment/prod/deployment/beta/*,./environment/prod/deployment/scripts/*" | |
target: ${{ secrets.TOBY_VPS_BETA_APP_PATH }} | |
rm: true | |
- name: run deployment script over ssh | |
uses: appleboy/[email protected] | |
with: | |
timeout: 10s | |
command_timeout: 10m | |
host: ${{ secrets.VPS_OVH_BF7EC892_HOST }} | |
port: ${{ secrets.VPS_OVH_BF7EC892_PORT }} | |
username: ${{ secrets.VPS_OVH_BF7EC892_USERNAME }} | |
key: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY }} | |
passphrase: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY_PASSPHRASE }} | |
script_stop: true | |
script: | | |
cd ${{ secrets.TOBY_VPS_BETA_APP_PATH }}/environment/prod/deployment/beta | |
make beta-deploy BETA_ENV_KEY=${{ secrets.BETA_ENV_KEY }} | |
docker images --filter dangling=true | grep "ghcr.io/blumilksoftware/${{ env.REPO_NAME }}" | awk '{print $3}'| xargs --no-run-if-empty docker rmi |