https://github.com/step-security/git-restore-mtime-action
A GitHub Workflow Action which restores timestamps of files in the current tree
https://github.com/step-security/git-restore-mtime-action
step-security-maintained-actions
Last synced: 8 months ago
JSON representation
A GitHub Workflow Action which restores timestamps of files in the current tree
- Host: GitHub
- URL: https://github.com/step-security/git-restore-mtime-action
- Owner: step-security
- License: mit
- Created: 2023-11-14T18:57:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-30T08:01:32.000Z (about 1 year ago)
- Last Synced: 2025-06-02T01:16:45.902Z (about 1 year ago)
- Topics: step-security-maintained-actions
- Language: Python
- Homepage: https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# git-restore-mtime action
A GitHub Workflow Action which restores timestamps of files in the current tree based on their last commit times. Uses the [git-restore-mtime](https://github.com/MestreLion/git-tools) script.
## Usage
The sample workflow below illustrates a static site build and deploy using the
[S3 Sync Action](https://github.com/jakejarvis/s3-sync-action). The `aws s3 sync` command relies on having the
correct timestamps for the files to be uploaded, thus, we must reset them before
running that action.
__NOTE__: git-restore-mtime uses the ref log to find the correct timestamp
for each file. This requires a full git history. See `checkout dist` task in
the example below.
```yaml
name: Build and Deploy
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
# Note: This is *only* for the very next step, it is not required by
# git-restore-mtime-action.
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 'latest'
# Run the build script which populates the ./dist folder
- name: build
run: |
yarn
yarn run build
# Merge ./dist into the 'gh-pages' branch (dist in this case)
- name: update dist branch
uses: peaceiris/actions-gh-pages@v2.3.1
env:
PERSONAL_TOKEN: ${{ secrets.ACCESS_TOKEN }}
PUBLISH_BRANCH: dist
PUBLISH_DIR: ./dist
# Check out the new branch
- name: checkout dist
uses: actions/checkout@v4
with:
ref: dist
# git-restore-mtime-bare uses the ref log to find the correct timestamp
# for each file. This requires a full git history. The default value (1)
# creates a shallow checkout.
fetch-depth: 0
# Fix timestamps
- name: restore timestamps
uses: step-security/git-restore-mtime-action@v2
# Upload to S3
- name: sync s3
uses: jakejarvis/s3-sync-action@2fb81a9e9fea11e078587911c27754e42e6a6e88
with:
args: --exclude '.git*/*' --delete --follow-symlinks
env:
SOURCE_DIR: './'
AWS_REGION: 'us-east-1'
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
```
### Configuration
```yaml
- name: restore timestamps
uses: step-security/git-restore-mtime-action@v2
with:
# Directory to change to before running the action. (Optional)
# Default: '.'
working-directory: '.'
```