Skip to content

Fix deploy script

Fix deploy script #2

Workflow file for this run

name: Deploy to Staging and Production
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy from'
required: true
default: 'master'
environment:
description: 'Environment to deploy to'
required: true
default: 'Staging'
type: choice
options:
- Staging
- Production
push:
branches:
- master
tags:
- 'v*'
jobs:
deploy:
runs-on: ubuntu-latest
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
run: echo "$DOCKERHUB_TOKEN" | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
- name: Determine environment
id: determine_env
run: |
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
echo "Selected environment: ${{ github.event.inputs.environment }}"
echo "environment=${{ github.event.inputs.environment }}" >> $GITHUB_OUTPUT
elif [[ ${{ github.ref }} == 'refs/heads/master' ]]; then
echo "Deploying to Staging due to push to master"
echo "environment=Staging" >> $GITHUB_OUTPUT
elif [[ ${{ github.ref }} == refs/tags/v* ]]; then
echo "Deploying to Production due to tag creation"
echo "environment=Production" >> $GITHUB_OUTPUT
fi
- name: Build Docker image
run: docker build -t stagecodes/otr-processor:${{ steps.determine_env.outputs.environment }} .
- name: Push Docker image to Docker Hub
run: docker push stagecodes/otr-processor:${{ steps.determine_env.outputs.environment }}