Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .github/actions/fetch-github-branch-sha/Dockerfile

This file was deleted.

23 changes: 19 additions & 4 deletions .github/actions/fetch-github-branch-sha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,28 @@
-->

# fetch-github-branch-sha docker action
This action queries for the latest git commit
sha on a github repo branch
This action queries for the latest git commit sha and latest tag on a GitHub repo branch.

## Inputs

### `owner`
The owner username or organization owning the GitHub repository containing the branch being queried

### `repo`
The name of the GitHub repository containing the branch being queried

### `branch`
The name of the branch being queried

## Outputs

### `sha` and `exit-code`
the commit sha from a github repo branch
### `sha`
the commit sha from a GitHub repo branch

### `latest-tag`
the latest tag on the branch

### `exit-code`
0 if the tests passed, 1 otherwise.

## Example usage
Expand Down
29 changes: 18 additions & 11 deletions .github/actions/fetch-github-branch-sha/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,30 @@
name: 'fetch-github-branch-sha'
description: 'Fetches the most recent commit from a github repository branch'
inputs:
owner:
owner:
description: 'The owner of the github repository ie, "apache"'
required: true
repo:
repo:
description: 'The owners github repository ie, "trafficcontrol"'
required: true
branch:
branch:
description: 'The repository branch to query ie, "8.1.0-branch"'
required: true
outputs:
sha:
description: 'The latest git commit sha'
description: 'The latest git commit sha on the given branch'
value: ${{ steps.entrypoint.outputs.sha }}
latest-tag:
description: 'The latest git tag on the given branch'
value: ${{ steps.entrypoint.outputs.latest-tag }}
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.owner }}
- ${{ inputs.repo }}
- ${{ inputs.branch }}

using: 'composite'
steps:
- id: entrypoint
env:
# No need to specify these environment variables once actions/runner#665 is fixed
INPUT_OWNER: ${{ inputs.owner }}
INPUT_REPO: ${{ inputs.repo }}
INPUT_BRANCH: ${{ inputs.branch }}
run: "${{ github.action_path }}/entrypoint.sh"
shell: bash
31 changes: 17 additions & 14 deletions .github/actions/fetch-github-branch-sha/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# specific language governing permissions and limitations
# under the License.
#
trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR;
set -o errexit -o nounset

# verify required environment inputs.
if [[ -z ${INPUT_OWNER} || -z ${INPUT_REPO} || -z ${INPUT_BRANCH} ]]; then
Expand All @@ -25,31 +27,32 @@ if [[ -z ${INPUT_OWNER} || -z ${INPUT_REPO} || -z ${INPUT_BRANCH} ]]; then
fi

# fetch the branch info
_brinfo=`curl --silent https://api.github.com/repos/${INPUT_OWNER}/${INPUT_REPO}/branches/${INPUT_BRANCH}`
_rc=$?

if [[ ${_rc} -ne 0 ]]; then
if ! _brinfo="$(curl --silent "${GITHUB_API_URL}/repos/${INPUT_OWNER}/${INPUT_REPO}/branches/${INPUT_BRANCH}")"; then
echo "Error: failed to fetch branch info ${INPUT_BRANCH}"
exit 2
fi

# parse out the commit sha
_sha=`echo -E ${_brinfo} | awk '{
if ($0 ~ /Branch not found/) {
print "BADBRANCH"
}
else if ($0 ~ /name/) {
print $7
}
}' | sed -e 's/[",]//g'`
_sha="$(<<<"$_brinfo" jq -r .name)"

# verify the sha
if [[ -z ${_sha} || ${_sha} == "BADBRANCH" ]]; then
if [[ -z "${_sha}" || "${_sha}" == "null" ]]; then
echo "Error: could not parse the commit from branch ${INPUT_BRANCH}"
exit 3
fi

echo "::set-output name=sha::${_sha}"

exit 0
branch_prefix_pattern="^$(<<<"$INPUT_BRANCH" grep -o '.*\.' | sed 's/\./\\./g')[0-9.]+$"

if ! tags_info="$(curl --silent "${GITHUB_API_URL}/repos/${INPUT_OWNER}/${INPUT_REPO}/tags")"; then
echo "Error: failed to fetch tag info ${INPUT_BRANCH}"
exit 2
fi

latest_tag="$(<<<"$tags_info" jq -r --arg BRANCH_PREFIX_PATTERN "$branch_prefix_pattern" '.[] | .name | select(test($BRANCH_PREFIX_PATTERN))' |
head -n1)"

echo "::set-output name=latest-tag::${latest_tag}"

exit 0
18 changes: 10 additions & 8 deletions .github/workflows/cache-config-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ on:
- GO_VERSION
- lib/go-atscfg/**.go
- traffic_ops/*client/**.go
- traffic_ops/toclientlib/**.go
- lib/atscfg-go/**.go
- traffic_ops/traffic_ops_golang/**.go
- cache-config/**.go
- cache-config/testing/**
- vendor/**.go
- vendor/modules.txt
- .github/actions/build-ats-test-rpm
- .github/actions/fetch-github-branch-sha
- .github/actions/cache-config-integration-tests
- .github/actions/build-ats-test-rpm/**
- .github/actions/fetch-github-branch-sha/**
- .github/actions/cache-config-integration-tests/**
create:
pull_request:
paths:
Expand All @@ -55,9 +57,9 @@ on:
- cache-config/testing/**
- vendor/**.go
- vendor/modules.txt
- .github/actions/build-ats-test-rpm
- .github/actions/fetch-github-branch-sha
- .github/actions/cache-config-integration-tests
- .github/actions/build-ats-test-rpm/**
- .github/actions/fetch-github-branch-sha/**
- .github/actions/cache-config-integration-tests/**
types: [opened, reopened, ready_for_review, synchronize]

jobs:
Expand Down Expand Up @@ -100,7 +102,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get commit sha
- name: Get latest commit sha and latest tag
uses: ./.github/actions/fetch-github-branch-sha
with:
owner: apache
Expand All @@ -112,7 +114,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/dist
key: ${{ steps.git-repo-sha.outputs.sha }}-el${{ env.RHEL_VERSION }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
key: ${{ steps.git-repo-sha.outputs.sha }}-${{ steps.git-repo-sha.outputs.latest-tag }}-el${{ env.RHEL_VERSION }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
- name: Build ATS RPM
if: steps.ats-rpm-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/build-ats-test-rpm
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/ciab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ on:
- 'docs/**'
- 'experimental/**'
- '.github/**'
- '!.github/actions/build-ciab/*'
- '!.github/actions/build-rpms/*'
- '!.github/actions/run-ciab/*'
- '!.github/actions/build-ciab/**'
- '!.github/actions/build-rpms/**'
- '!.github/actions/fetch-github-branch-sha/**'
- '!.github/actions/run-ciab/**'
- '!infrastructure/cdn-in-a-box/optional/**'
- '!.github/workflows/ciab.yaml'
- 'infrastructure/ansible/**'
Expand All @@ -61,9 +62,10 @@ on:
- 'docs/**'
- 'experimental/**'
- '.github/**'
- '!.github/actions/build-ciab/*'
- '!.github/actions/build-rpms/*'
- '!.github/actions/run-ciab/*'
- '!.github/actions/build-ciab/**'
- '!.github/actions/build-rpms/**'
- '!.github/actions/fetch-github-branch-sha/**'
- '!.github/actions/run-ciab/**'
- '!infrastructure/cdn-in-a-box/optional/**'
- '!.github/workflows/ciab.yaml'
- 'infrastructure/ansible/**'
Expand Down Expand Up @@ -225,7 +227,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get commit sha
- name: Get latest commit sha and latest tag
uses: ./.github/actions/fetch-github-branch-sha
with:
owner: apache
Expand All @@ -237,7 +239,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/dist
key: ${{ steps.git-repo-sha.outputs.sha }}-el${{ env.RHEL_VERSION }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
key: ${{ steps.git-repo-sha.outputs.sha }}-${{ steps.git-repo-sha.outputs.latest-tag }}-el${{ env.RHEL_VERSION }}-${{ hashFiles('cache-config/testing/docker/trafficserver/**') }}
- name: Build ATS RPM
if: steps.ats-rpm-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/build-ats-test-rpm
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/cdn-in-a-box/bin/ats-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ remote_ats_version() {
tail -n1)"

# $release is the number of commits between $release to $branch.
release="$(curl -fs "${gitbox_url}?p=${repo};a=shortlog;h=${branch};hp=${last_tag}" | grep -c 'class="link"')"
page_output="$(curl -fs "${gitbox_url}?p=${repo};a=shortlog;h=${branch};hp=${last_tag}")"
release="$(<<<"$page_output" grep -c 'class="link"' || true)"
<<<"${last_tag}-${release}.${commit:0:9}" tee "$ats_version_file"
}

Expand Down
8 changes: 6 additions & 2 deletions infrastructure/cdn-in-a-box/traffic_portal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ ARG TO_HOST=$TO_HOST

# Install and delete the TRAFFIC_PORTAL_RPM when finished
RUN dnf install -y \
epel-release && \
epel-release yum-utils && \
### Remove these lines once nodesource/distributions#1290 is fixed
set -o pipefail && \
yumdownloader -q --url nodejs | xargs dnf -y install && \
###
dnf install -y \
jq \
nodejs \
#nodejs
openssl \
gettext \
bind-utils \
Expand Down