Skip to content

Merge pull request #54 from Giveth/staging #283

Merge pull request #54 from Giveth/staging

Merge pull request #54 from Giveth/staging #283

Workflow file for this run

name: CI/CD
on: [push, pull_request]
jobs:
publish:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ghcr.io
repository: giveth/givback-calculation
add_git_labels: true
# Add branch name to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref}
tag_with_ref: true
# Add commit hash to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha}
tag_with_sha: true
deploy:
if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master'
needs: publish
runs-on: ubuntu-latest
steps:
- name: production deploy
if: github.ref == 'refs/heads/master'
uses: appleboy/[email protected]
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USERNAME }}
key: ${{ secrets.PROD_PRIVATE_KEY }}
port: 22
script: |
cd $HOME/givback-calculation-production
git checkout master
git checkout -- .
git pull
docker compose -f docker-compose-production.yml pull
docker compose -f docker-compose-production.yml down
docker compose -f docker-compose-production.yml up -d
docker image prune -a --force
- name: staging deploy
if: github.ref == 'refs/heads/staging'
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: 22
script: |
cd $HOME/givback-calculation-staging
git checkout staging
git checkout -- .
git pull
docker compose -f docker-compose-staging.yml pull
docker compose -f docker-compose-staging.yml down
docker compose -f docker-compose-staging.yml up -d
docker image prune -a --force