chore: add a step to validate branch name in Build Artifacts for PRs workflow #32
Workflow file for this run
This file contains 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: Build Artifacts for PRs | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
jobs: | |
generate-tag: | |
name: Generate docker tag | |
runs-on: ubuntu-latest | |
outputs: | |
image_tag: ${{steps.gen_tag_names.outputs.tag_name}} | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 1 | |
- name: Validate Branch Name | |
id: validate_branch_name | |
run: | | |
# Perform input validation here | |
# For example, check for forbidden characters | |
if [[ "${{ github.head_ref }}" =~ [^a-zA-Z0-9._-] ]]; then | |
echo "Error: Branch name contains invalid characters." | |
exit 1 | |
fi | |
# Replace problematic characters in branch name (like '/') with safe characters (like '.') | |
- name: Generate Tag Names | |
id: gen_tag_names | |
run: | | |
tag_name=$(echo ${{ github.head_ref }} | tr "/" .) | |
echo "Tag Name: $tag_name" | |
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT | |
build: | |
name: Build Shopify Tracker Docker Image | |
uses: ./.github/workflows/build-and-push-docker-image.yml | |
needs: [generate-tag] | |
with: | |
img_tag: ${{ needs.generate-tag.outputs.image_tag }} | |
secrets: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |