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

Able to wipe git history for master/main branch #36

Closed
Technetium1 opened this issue Jul 24, 2022 · 3 comments
Closed

Able to wipe git history for master/main branch #36

Technetium1 opened this issue Jul 24, 2022 · 3 comments

Comments

@Technetium1
Copy link

This needs to have a warning. The action should not destroy the commit history. Luckily GitHub support was able to recover my last commit.

Example:

name: Snake

on:
  # run automatically every 6 hours
  schedule:
    - cron: "0 */6 * * *"

# This command allows us to run the Action automatically from the Actions tab.
  workflow_dispatch:
  
  push:
    branches:
    - master

jobs:
  generate:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    
    steps:
      # generates a snake game from a github user (<github_user_name>) contributions graph, output a svg animation at <svg_out_path>
      - name: generate github-contribution-grid-snake.svg
        uses: Platane/snk/svg-only@v2
        with:
          github_user_name: ${{ github.repository_owner }}
          outputs: |
            snake/github-contribution-grid-snake.svg?color_snake=purple
            snake/github-contribution-grid-snake-dark.svg?palette=github-dark&color_snake=purple
      # push the content of <build_dir> to a branch
      # the content will be available at https://raw.githubusercontent.com/<github_user>/<repository>/<target_branch>/<file> , or as github page
      - name: push github-contribution-grid-snake.svg to the output branch
        uses: crazy-max/ghaction-github-pages@v2.6.0
        with:
          target_branch: master
          build_dir: dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@Technetium1
Copy link
Author

Related #13

@Platane
Copy link
Owner

Platane commented Jul 25, 2022

How would you want me to address this ?

As you noticed this action ( Platane/snk ) did not manipulate your git repository. The second one ( crazy-max/ghaction-github-pages) did. There are already comments to explain what each action does.

@huuquyet
Copy link

huuquyet commented May 4, 2024

I found the way to commit files without overwrite the output branch,
just use actions/checkout@v4 instead of crazy-max/ghaction-github-pages:

    steps:
+      # checkout output branch 
+      - name: checkout output branch
+        uses: actions/checkout@v4
+        with:
+          ref: output

      # generates a snake game from a github user (<github_user_name>) contributions graph, output a svg animation at <svg_out_path>
      - name: generate github-contribution-grid-snake.svg
        uses: Platane/snk/svg-only@v3
        with:
          github_user_name: ${{ github.repository_owner }}
          outputs: |
-            dist/github-contribution-grid-snake.svg
-            dist/github-contribution-grid-snake-dark.svg?palette=github-dark
            ./github-contribution-grid-snake.svg
            ./github-contribution-grid-snake-dark.svg?palette=github-dark
      # push the content of <build_dir> to a branch
      # the content will be available at https://raw.githubusercontent.com/<github_user>/<repository>/<target_branch>/<file> , or as github page
      - name: push github-contribution-grid-snake.svg to the output branch
-        uses: crazy-max/ghaction-github-pages@v3.1.0
-        with:
-          target_branch: output
-          build_dir: dist
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          git config user.name "github-actions[bot]"
+          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+          git add .
+          git commit -m "Update github-contribution-grid-snake by [bot]"
+          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

3 participants