Cards #172
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
| # ============================================================================= | |
| # ARO Programming Language - Cards Pipeline | |
| # ============================================================================= | |
| # Builds and pushes the ARO Cards Docker image to GitHub Container Registry | |
| # - On main: tags with short commit hash (e.g., d04f2e8) | |
| # - On tag: tags with version number (e.g., 2.3.1) | |
| # ============================================================================= | |
| name: Cards | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*.*.*' | |
| paths: | |
| - 'cards/**' | |
| - '.github/workflows/cards.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'cards/**' | |
| - '.github/workflows/cards.yml' | |
| workflow_dispatch: | |
| schedule: | |
| # Run Monday-Friday at 9:00 AM UTC | |
| - cron: '0 9 * * 1-5' | |
| concurrency: | |
| group: cards-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository_owner }}/aro-cards | |
| jobs: | |
| # =========================================================================== | |
| # Build and Push Docker Image | |
| # =========================================================================== | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 | |
| - name: Log in to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) | |
| id: meta | |
| uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| # On main branch: use short SHA | |
| type=sha,prefix=,format=short,enable=${{ github.ref == 'refs/heads/main' }} | |
| # On version tags: use semver (strips 'v' prefix) | |
| type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
| # Latest tag for main branch | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6 | |
| with: | |
| context: ./cards | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Output image info | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| echo "## Docker Image Published" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Registry:** ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tags:**" >> $GITHUB_STEP_SUMMARY | |
| echo '${{ steps.meta.outputs.tags }}' | tr ',' '\n' | while read tag; do | |
| echo "- \`$tag\`" >> $GITHUB_STEP_SUMMARY | |
| done | |
| # =========================================================================== | |
| # Post Card to Mastodon (scheduled daily Monday-Friday) | |
| # =========================================================================== | |
| post: | |
| name: Post Card to Mastodon | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| # Only run on schedule or manual trigger, not on code changes | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: | | |
| cd cards | |
| npm install | |
| - name: Generate cards | |
| run: | | |
| cd cards | |
| node generate.js | |
| - name: Post card to Mastodon | |
| env: | |
| MASTODON_INSTANCE: ${{ secrets.MASTODON_INSTANCE }} | |
| MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} | |
| START_DATE: '2026-01-01' | |
| run: | | |
| cd cards | |
| node post-to-mastodon.js |