name: Deploy Portfolio on: push: branches: [main] workflow_dispatch: jobs: deploy: runs-on: self-hosted steps: - name: Checkout code run: | rm -rf * .git git clone "https://code.chagarlamudi.net/raghu-ch/rc-portfolio.git" . - name: Build Docker image run: docker build -t rc-portfolio:latest . - name: Stop old container run: docker stop rc-portfolio || true - name: Remove old container run: docker rm rc-portfolio || true - name: Run new container run: | docker run -d \ --name rc-portfolio \ --restart unless-stopped \ -p 8080:80 \ rc-portfolio:latest - name: Clean up old images run: docker image prune -f - name: Install curl run: | if ! command -v curl >/dev/null 2>&1; then if command -v apt >/dev/null 2>&1; then apt update && sudo apt install -y curl elif command -v apk >/dev/null 2>&1; then apk add curl elif command -v yum >/dev/null 2>&1; then yum install -y curl fi fi - name: Set Discord mention id: discord run: | echo "mention=<@${{ secrets.DISCORD_ID_RAGHU }}>" >> $GITEA_OUTPUT # Success notification - name: Discord Success Notification if: success() run: | curl -X POST -H "Content-Type: application/json" \ -d "{ \"content\": \"โœ… **Deployment SUCCESS**\n\ ๐Ÿง‘โ€๐Ÿ’ป ${{ steps.discord.outputs.mention }}\n\ ๐Ÿ—‚๏ธ Repo: ${{ gitea.repository }}\n\ ๐ŸŒฒ Branch: ${{ gitea.ref_name }}\n\ ๐Ÿงท Commit: [${{ steps.commit.outputs.short_sha }}](${{ steps.commit.outputs.url }})\n\ โœ๏ธ Message: ${{ steps.message.outputs.msg }}\" }" \ ${{ secrets.DISCORD_WEBHOOK_URL }} # Failure notification - name: Discord Failure Notification if: failure() run: | curl -X POST -H "Content-Type: application/json" \ -d "{ \"content\": \"โŒ **Deployment FAILED**\n\ ๐Ÿง‘โ€๐Ÿ’ป ${{ steps.discord.outputs.mention }}\n\ ๐Ÿ—‚๏ธ Repo: ${{ gitea.repository }}\n\ ๐ŸŒฒ Branch: ${{ gitea.ref_name }}\n\ ๐Ÿงท Commit: [${{ steps.commit.outputs.short_sha }}](${{ steps.commit.outputs.url }})\n\ โœ๏ธ Message: ${{ steps.message.outputs.msg }}\n\ ๐Ÿ” Check Gitea Actions logs\" }" \ ${{ secrets.DISCORD_WEBHOOK_URL }}