name: Main CI-Frontend on: workflow_dispatch: push: branches: - main paths: - 'client/**/*.html' - 'client/**/*.png' - 'client/**/*.json' - 'client/**/*.txt' - 'client/**/*.ts' - 'client/**/*.tsx' - 'client/**/*.js' - 'client/Dockerfile' - 'client/Caddyfile' - '.github/workflows/ci-main-frontend.yml' jobs: build-and-push: name: Build & Push runs-on: easynode-debian permissions: contents: write packages: write steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Docker Buildx run: docker buildx inspect --bootstrap - name: Log in to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Find PR number id: find_pr run: | PR_NUMBER=$(curl -s \ -H "Authorization: token ${{ secrets.REGISTRY_TOKEN }}" \ "https://lightroasted.vps-kinghost.net/api/v1/repos/${{ github.repository }}/commits/${{ github.sha }}/pull" \ | jq -r 'if type == "object" and .number != null then .number | tostring else empty end') if [ -z "$PR_NUMBER" ]; then echo "No merged PR found for this commit. Falling back to 'candidate' tag." PR_NUMBER="candidate" else PR_NUMBER="pr-${PR_NUMBER}" fi echo "tag=${PR_NUMBER}" >> $GITHUB_OUTPUT - name: Extract version from image id: version run: | docker pull rmcampos/tasknote-app:${{ steps.find_pr.outputs.tag }} VITE_BUILD=$(docker inspect rmcampos/tasknote-app:${{ steps.find_pr.outputs.tag }} \ --format '{{ range .Config.Env }}{{ println . }}{{ end }}' \ | grep '^VITE_BUILD=' | cut -d= -f2) if [ -z "$VITE_BUILD" ]; then echo "Could not extract VITE_BUILD from image" >&2 exit 1 fi echo "tag=${VITE_BUILD}" >> $GITHUB_OUTPUT echo "Extracted version: ${VITE_BUILD}" - name: Promote Docker image run: | docker buildx imagetools create \ --tag rmcampos/tasknote-app:latest \ rmcampos/tasknote-app:${{ steps.find_pr.outputs.tag }} - name: Create and push Git tag run: | git config user.name "gitea-actions[bot]" git config user.email "gitea-actions[bot]@noreply.lightroasted.vps-kinghost.net" git tag -a ${{ steps.version.outputs.tag }} -m "Release ${{ steps.version.outputs.tag }}" git push origin ${{ steps.version.outputs.tag }}