-
Notifications
You must be signed in to change notification settings - Fork 2
49 lines (44 loc) · 1.42 KB
/
build-pr-artifacts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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:
ref: ${{ github.event.pull_request.head.sha }}
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 }}