Skip to content

Automation of Branch Names for a Simple Standard Build Workflow #45

@dave2wave

Description

@dave2wave

It should be possible to create and use a standard workflow that automatically takes into account the branch name and our convention about the output brand a prototype is here: https://github.com/apache/petri/blob/dfoulks/pelican-gha/.github/workflows/build-pelican.yml

Note that the following part covers the automation of changes on branches:

on:
  push:
    branches: 
      - 'preview/**'
  pull_request:
    branches: 
      - 'preview/**'
  workflow_dispatch:

We might need an excludes.

The other part computes the branch names and should become part of our standard action:

jobs:
  build-pelican:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.inputs.branch || github.head_ref || github.ref }}
      - name: Determine branch name
        id: get_branch
        run: |
          # Get the current branch name
          echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
      - name: Branch
        run: |
          echo "Branch: ${{ env.BRANCH_NAME }}"
          if [ "${{ env.BRANCH_NAME }}" == "${{ github.event.repository.default_branch }}" ]; then
            echo "OUTPUT_BRANCH=asf-site" >> $GITHUB_ENV
          else
            echo "OUTPUT_BRANCH=${{ env.BRANCH_NAME }}-staging" >> $GITHUB_ENV
          fi
      - name: Pelican  Build
        uses: apache/infrastructure-actions/pelican@main
        with:
          destination: ${{ env.OUTPUT_BRANCH }}

Making the destination part of the automation means that the pelican action should babe able to need no inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions