updating yml file #12
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: "Build and Push to GHCR" | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
Deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GHCR_USERNAME }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Build and Push for Frontend Github Registry | |
if: github.ref == 'refs/heads/main' | |
env: | |
DEV_ENV_FILE: ${{ secrets.ENV_FILE }} | |
run: | | |
echo "$DEV_ENV_FILE" > .env | |
export CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr '[:upper:]' '[:lower:]') | |
export TAG=$([[ $CURRENT_BRANCH == $(basename ${{ github.ref }}) ]] && echo $CURRENT_BRANCH || echo "latest") | |
echo $TAG | |
export GITHUB_REF_IMAGE=$(echo ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA | tr '[:upper:]' '[:lower:]') | |
export GITHUB_BRANCH_IMAGE=$(echo ghcr.io/$GITHUB_REPOSITORY:$TAG | tr '[:upper:]' '[:lower:]') | |
docker build --build-arg version=$GITHUB_SHA -t $GITHUB_REF_IMAGE -t $GITHUB_BRANCH_IMAGE . | |
echo "Pushing Frontend Image to GitHub Container Registry" | |
docker push $GITHUB_REF_IMAGE | |
docker push $GITHUB_BRANCH_IMAGE | |
rm -rf .env | |
- name: Deploy on Frontend Dev server | |
if: github.ref == 'refs/heads/main' | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEV_REMOTE_SERVER_ADDRESS }} | |
username: ${{ secrets.DEV_SERVER_USERNAME }} | |
key: ${{ secrets.DEV_REMOTE_SERVER_KEY }} | |
port: ${{ secrets.DEV_SSH_PORT }} | |
script: | | |
pwd | |
# docker discover || true && docker image rm ghcr.io/myriadflow/discover:main | |
echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin | |
docker stop discover && docker rm discover && docker rmi ghcr.io/myriadflow/discover:main | |
docker pull ghcr.io/myriadflow/discover:main | |
docker run --name="discover" --rm -p 3000:6060 -d ghcr.io/myriadflow/discover:main |