CB-22 Fix typo #28
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 Docker Hub | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Log in to Docker Hub | |
run: | | |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login docker.io -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Build and push Docker image for staging or production | |
run: | | |
# Determine the image tag and event type based on the branch | |
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then | |
IMAGE_TAG="staging-${{ github.sha }}" | |
EVENT_TYPE="deploy_chatbot_staging" | |
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
IMAGE_TAG="prod-${{ github.sha }}" | |
EVENT_TYPE="deploy_chatbot_production" | |
else | |
echo "Unsupported branch: ${{ github.ref }}. Exiting." | |
exit 1 | |
fi | |
# Define the image name and full image path | |
IMAGE_NAME="chatbot-builder-executor" | |
IMAGE_FULL_NAME="docker.io/${{ secrets.DOCKER_USERNAME }}/${IMAGE_NAME}:${IMAGE_TAG}" | |
# Build and push the Docker image to Docker Hub | |
docker build -t "$IMAGE_FULL_NAME" . | |
docker push "$IMAGE_FULL_NAME" | |
# Export variables for use in the next steps | |
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV | |
echo "IMAGE_FULL_NAME=${IMAGE_FULL_NAME}" >> $GITHUB_ENV | |
echo "EVENT_TYPE=${EVENT_TYPE}" >> $GITHUB_ENV | |
- name: Trigger deployment in infra repo | |
run: | | |
curl -X POST \ | |
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ | |
-H "Accept: application/vnd.github.everest-preview+json" \ | |
https://api.github.com/repos/Chatbot-Builder-Project/chatbot-builder-infra/dispatches \ | |
-d '{"event_type":"'"${{ env.EVENT_TYPE }}"'", "client_payload": {"image_full_name": "'"${{ env.IMAGE_FULL_NAME }}"'", "image_manifest_name": "'"${{ env.IMAGE_NAME }}"'"}}' |