Weekly Memo Archive #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Weekly Memo Archive | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 0' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| archive: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if [ ! -d "src/memos" ]; then | |
| echo "Directory src/memos not found. Skipping archive." | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| LAST_TAG=$(git describe --tags --match "archive-*" --abbrev=0 2>/dev/null || echo "") | |
| if [ -z "$LAST_TAG" ]; then | |
| echo "No previous archive found. Proceeding..." | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Last archive tag: $LAST_TAG" | |
| if git diff --quiet "$LAST_TAG" HEAD -- src/memos; then | |
| echo "No changes in src/memos since $LAST_TAG." | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected in src/memos." | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| fi | |
| - name: Get current date | |
| if: steps.check_changes.outputs.has_changes == 'true' | |
| id: date | |
| run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| - name: Create archive | |
| if: steps.check_changes.outputs.has_changes == 'true' | |
| run: | | |
| cd src | |
| zip -r ../memos-${{ steps.date.outputs.date }}.zip memos | |
| - name: Create Release | |
| if: steps.check_changes.outputs.has_changes == 'true' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: archive-${{ steps.date.outputs.date }} | |
| name: Memo Archive ${{ steps.date.outputs.date }} | |
| draft: false | |
| prerelease: false | |
| files: memos-${{ steps.date.outputs.date }}.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |