docker build for hosting migration #2
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: CI | |
on: | |
push | |
env: | |
IMAGE_NAME: apoland/indyhackers | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
image: ${{ steps.build-image.outputs.image }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: apoland | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build, tag, and push image to Dockerhub | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
docker build -t $IMAGE_NAME:$IMAGE_TAG . | |
docker push $IMAGE_NAME:$IMAGE_TAG | |
echo "image=$IMAGE_NAME:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
cd: | |
if: github.ref == 'refs/heads/main' | |
needs: [build] | |
uses: ./.github/workflows/cd.yml | |
with: | |
image: ${{ needs.build.outputs.image }} | |
ssh_user: indyhackers | |
ssh_host: indyhackersdev.highcapacity.net | |
secrets: | |
ssh_key: ${{ secrets.SSH_KEY_DEV }} |