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

[Docs] Commit and push only subdir to another branch (GitHub/CodeBerg Pages) #94

Open
vivi90 opened this issue Dec 7, 2023 · 2 comments

Comments

@vivi90
Copy link

vivi90 commented Dec 7, 2023

I have currently a workflow with an build step and a deploy step, that works as expected:

when:
  - event: push
    branch: main

steps:
  build:
    image: node:slim
    commands:
      - corepack enable
      - pnpm install --frozen-lockfile
      - pnpm run build

  deploy:
    image: alpine/git
    secrets:
      - git_token
    environment:
      - BUILD_DIR=dist
      - TARGET_BRANCH=pages
    commands:
      # Git configuration
      - git config --global user.name "$CI_COMMIT_AUTHOR"
      - git config --global user.email "$CI_COMMIT_AUTHOR_EMAIL"
      - git clone -b $TARGET_BRANCH https://$GIT_TOKEN@codeberg.org/${CI_REPO}.git $TARGET_BRANCH
      # Copy build
      - cp -ar $BUILD_DIR/. $TARGET_BRANCH/
      - cp .domains $CI_REPO_NAME || true # Ignore if it doesn't exist
      # Commit & Push
      - cd $TARGET_BRANCH
      - git add .
      - git diff-index --quiet HEAD || git commit -m "$CI_COMMIT_MESSAGE"
      - git push

How can i achieve the same as:

...

steps:
  ...

  deploy:
    image: alpine/git
    secrets:
      - git_token
    environment:
      - BUILD_DIR=dist
      - TARGET_BRANCH=pages
    commands:
      # Git configuration
      - git config --global user.name "$CI_COMMIT_AUTHOR"
      - git config --global user.email "$CI_COMMIT_AUTHOR_EMAIL"
      - git clone -b $TARGET_BRANCH https://$GIT_TOKEN@codeberg.org/${CI_REPO}.git $TARGET_BRANCH
      # Copy build
      - cp -ar $BUILD_DIR/. $TARGET_BRANCH/
      - cp .domains $CI_REPO_NAME || true # Ignore if it doesn't exist
      # Commit & Push
      - cd $TARGET_BRANCH
      - git add .
      - git diff-index --quiet HEAD || git commit -m "$CI_COMMIT_MESSAGE"
      - git push

but with appleboy/drone-git-push?

@appleboy
Copy link
Owner

@vivi90 Yes, you can try it out.

@vivi90
Copy link
Author

vivi90 commented Mar 10, 2024

@appleboy

@vivi90 Yes, you can try it out.

That's the point.. did not find an working solution with appleboy/drone-git-push

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

2 participants