mitlist/.gitea/workflows/deploy-prod.yml
mohamad ed76816a32
Some checks failed
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Failing after 1m26s
Enhance deployment workflow with context variable debugging and fallback logic
2025-06-01 14:50:52 +02:00

81 lines
2.9 KiB
YAML

name: Deploy to Production, build images and push to Gitea Registry
on:
pull_request:
types: [closed]
branches:
- prod
jobs:
build_and_push:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Docker
run: |
sudo apt-get update
sudo apt-get install -y docker.io
- name: Debug context variables
run: |
echo "Actor: ${{ gitea.actor }}"
echo "Repository: ${{ gitea.repository_name }}"
echo "Repository owner: ${{ gitea.repository_owner }}"
echo "Event repository name: ${{ gitea.event.repository.name }}"
echo "Event repository full name: ${{ gitea.event.repository.full_name }}"
- name: Build and push backend image
env:
GITEA_USERNAME: ${{ secrets.ME_USERNAME }}
GITEA_PASSWORD: ${{ secrets.ME_PASSWORD }}
run: |
echo $GITEA_PASSWORD | docker login git.vinylnostalgia.com -u $GITEA_USERNAME --password-stdin
# Try different context variable combinations
REPO_NAME="${{ gitea.repository_name }}"
ACTOR="${{ gitea.actor }}"
OWNER="${{ gitea.repository_owner }}"
# Use fallback if variables are empty
if [ -z "$REPO_NAME" ]; then
REPO_NAME="${{ gitea.event.repository.name }}"
fi
if [ -z "$ACTOR" ]; then
ACTOR="${{ gitea.event.repository.owner.login }}"
fi
echo "Using ACTOR: $ACTOR"
echo "Using REPO_NAME: $REPO_NAME"
docker build -t git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest ./be -f ./be/Dockerfile.prod
docker push git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest
- name: Build and push frontend image
env:
GITEA_USERNAME: ${{ secrets.ME_USERNAME }}
GITEA_PASSWORD: ${{ secrets.ME_PASSWORD }}
run: |
echo $GITEA_PASSWORD | docker login git.vinylnostalgia.com -u $GITEA_USERNAME --password-stdin
# Try different context variable combinations
REPO_NAME="${{ gitea.repository_name }}"
ACTOR="${{ gitea.actor }}"
OWNER="${{ gitea.repository_owner }}"
# Use fallback if variables are empty
if [ -z "$REPO_NAME" ]; then
REPO_NAME="${{ gitea.event.repository.name }}"
fi
if [ -z "$ACTOR" ]; then
ACTOR="${{ gitea.event.repository.owner.login }}"
fi
echo "Using ACTOR: $ACTOR"
echo "Using REPO_NAME: $REPO_NAME"
docker build -t git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest ./fe -f ./fe/Dockerfile.prod
docker push git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest