updating port #23
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 | |
- prod | |
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 Docker Image | |
run: | | |
export CURRENT_BRANCH=${GITHUB_REF#refs/heads/} | |
export TAG=$([[ $CURRENT_BRANCH == $(basename ${{ github.ref }}) ]] && echo $CURRENT_BRANCH || echo "latest") | |
export GITHUB_REF_IMAGE=ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA | |
export GITHUB_BRANCH_IMAGE=ghcr.io/$GITHUB_REPOSITORY:$TAG | |
docker build -t $GITHUB_REF_IMAGE -t $GITHUB_BRANCH_IMAGE . | |
echo "Pushing Image to GitHub Container Registry" | |
docker push $GITHUB_REF_IMAGE | |
docker push $GITHUB_BRANCH_IMAGE | |
- name: Deploy on 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 | |
cd superiad | |
sudo podman stop superiad && sudo podman rm superiad && sudo podman image rm superiad | |
echo ${{ secrets.GHCR_TOKEN }} | sudo podman login ghcr.io -u secrets.GHCR_USERNAME --password-stdin | |
sudo podman pull ghcr.io/weareflexable/superiad:main | |
sudo podman run --name="superiad" --env-file=.env -p 9090:9090 --net=bridge -d ghcr.io/weareflexable/superiad:main | |
- name: Deploy on PROD server | |
if: github.ref == 'refs/heads/prod' | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.PROD_REMOTE_SERVER_ADDRESS }} | |
username: ${{ secrets.PROD_SERVER_USERNAME }} | |
key: ${{ secrets.PROD_REMOTE_SERVER_KEY }} | |
port: ${{ secrets.PROD_SSH_PORT }} | |
script: | | |
pwd | |
cd superiad | |
sudo podman stop superiad && sudo podman rm superiad && sudo podman image rm superiad | |
echo ${{ secrets.GHCR_TOKEN }} | podman login ghcr.io -u secrets.GHCR_USERNAME --password-stdin | |
sudo podman pull ghcr.io/weareflexable/superiad:prod | |
sudo podman run --name="superiad" --env-file=.env -p 9080:8080 --net=bridge -d ghcr.io/weareflexable/superiad:prod |