Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delta Syning combined with push action not working #38

Open
AlexMi-Ha opened this issue Jul 6, 2024 · 0 comments
Open

Delta Syning combined with push action not working #38

AlexMi-Ha opened this issue Jul 6, 2024 · 0 comments

Comments

@AlexMi-Ha
Copy link

AlexMi-Ha commented Jul 6, 2024

My Workflow starts when I push to main, builds the project and pushes the artifact from the dest folder to the gh-pages branch.
Now I want to sync the gh-pages branch to my sftp server.
This does not work, as the sftp action gets the changes from the main branch not from the gh-pages branch.

When using the delta mode, the script still looks at the latest commit in the main branch not in the gh-pages branch, because the {{github.sha}} variable points to main, as main triggered the workflow.

The action should use git cli to determine the latest commit and not rely on the github context.

Example workflow:

on:
  push:
    branches:
      - main
jobs:
  build:
    runs-on: ubuntu-latest
    name: Build and Push
    steps:
      - name: git-checkout
        uses: actions/checkout@v2 
      - name: Build
        run: |
          build.sh
      - name: Push
        uses: s0/git-publish-subdir-action@develop
        env:
          REPO: self
          BRANCH: gh-pages
          FOLDER: dest/
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          MESSAGE: "Build: ({sha}) {msg}"

  deploy:
    runs-on: ubuntu-latest
    name: Deploy to FTP
    needs: build
    steps:
      - name: git-checkout
        uses: actions/checkout@v2 
        with:
          fetch-depth: 0
          ref: gh-pages
          
      - name: Sync to FTP server
        uses: milanmk/actions-file-deployer@master
        with:
          remote-protocol: sftp
          remote-host: ${{ secrets.FTP_HOST }}
          remote-user: ${{ secrets.FTP_USER }}
          remote-password: ${{ secrets.FTP_PASSWORD }}
          remote-path: /prod
          remote-port: ${{ secrets.FTP_PORT }}

Already tried putting the sftp action into another workflow which triggers on push to gh-pages, but a push by the GTIHUB_TOKEN credentials does not trigger workflows - i would have to use a PAT :(

With full sync, everything works, because no commit history is looked at and the {{ github.sha }} is not referenced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant