Github

# Use the no-reply email
git config --list --show-origin |t

# Set your email to the no-reply address locally for this repo
git config user.email "ID+username@users.noreply.github.com"

# Or set it globally for all repos
git config --global user.email "ID+username@users.noreply.github.com"

# Reset the author of your last commit
git commit --amend --reset-author --no-edit

# Or if you have multiple unpushed commits, reset all since origin
# Mark commits as 'edit', then for each:
git rebase -i origin/main  # or origin/master
git commit --amend --reset-author --no-edit
git rebase --continue

echo "$GHCR_PAT"|docker login ghcr.io -u ${GITUSER} --password-stdin

# set new origin
git remote set-url origin git@github.com:mroverton/dev-notes.git

# to allow server pulls
echo $GITHUB_TOKEN | docker login ghcr.io -u mroverton --password-stdin    
  • GitHub Actions
    • Example workflow
      name: Build and Push Docker Images
      
      on:
        push:
          branches:
            - main
          paths:
            - 'api/**'
            - 'frontend/**'
            - 'gatherer/**'
            - '.github/workflows/build-and-push-images.yml'
        workflow_dispatch:
      
      env:
        REGISTRY: ghcr.io
        IMAGE_PREFIX: ${{ github.repository }}
        VERSION_PREFIX: "1.2"                                                                       
        FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
      
      jobs:
        build-cloudview-api:
          runs-on: ubuntu-latest
          permissions:
            contents: read
            packages: write
          steps:
            - name: Checkout repository
              uses: actions/checkout@v4
            - name: Set up Docker Buildx
              uses: docker/setup-buildx-action@v4
            - name: Log in to GitHub Container Registry
              uses: docker/login-action@v3
              with:
                registry: ${{ env.REGISTRY }}
                username: ${{ github.actor }}
                password: ${{ secrets.GITHUB_TOKEN }}
            - name: Extract metadata
              id: meta
              uses: docker/metadata-action@v5
              with:
                images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/cloudview-api
                tags: |
                  type=ref,event=branch
                  type=raw,value=${{ env.VERSION_PREFIX }}.${{ github.run_number }},enable={{is_default_branch}}
                  type=sha,prefix={{branch}}-
                  type=raw,value=latest,enable={{is_default_branch}}
            - name: Build and push image
              uses: docker/build-push-action@v5
              with:
                context: ./api
                file: ./api/Dockerfile
                push: ${{ github.event_name != 'pull_request' }}
                tags: ${{ steps.meta.outputs.tags }}
                labels: ${{ steps.meta.outputs.labels }}
                cache-from: type=gha
                cache-to: type=gha,mode=max
      
      
        deploy:
          needs: [build-cloudview-api,build-cloudview-front,build-cloudview-gather]
          runs-on: ubuntu-latest
          if: github.event_name == 'push' && github.ref == 'refs/heads/main'
          permissions:
            contents: write
          steps:
            - name: Checkout repository
              uses: actions/checkout@v4
              with:
                fetch-depth: 0
            - name: Create and push version tag
              run: |
                VERSION="v${{ env.VERSION_PREFIX }}.${{ github.run_number }}"
                git config user.name "github-actions[bot]"
                git config user.email "github-actions[bot]@users.noreply.github.com"
                git tag -a "$VERSION" -m "Release $VERSION"
                git push origin "$VERSION"
            - name: Deploy to Production
              uses: appleboy/ssh-action@v1.2.5
              with:
                host: ${{ vars.TARGET_HOST }}
                username: ${{ vars.TARGET_USER }}
                key: ${{ secrets.TARGET_KEY }}
                envs: GHCR_PAT,GITHUB_ACTOR
                script: |
                  cd $HOME/home-bastion/service
                  VERSION="${{ env.VERSION_PREFIX }}.${{ github.run_number }}"
                  grep -q '^CLOUD_VERSION=' .env 2>/dev/null && sed -i "s/^CLOUD_VERSION=.*/CLOUD_VERSION=$VERSION/" .env || echo "CLOUD_VERSION=$VERSION" >> .env
                  echo "$GHCR_PAT" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
                  docker compose pull
                  docker compose up -d