5757 CWA_GITHUB_TEST_REPO_NAME : ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}
5858 CWA_GITHUB_TEST_REPO_URL : ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_URL }}
5959 CWA_GITHUB_TEST_REPO_BRANCH : ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
60+ CWA_COMMIT_DATE : ${{ steps.get-commit-date.outputs.commit_date }}
6061 steps :
6162 - name : SetOutputs
6263 id : set-outputs
@@ -67,12 +68,51 @@ jobs:
6768 echo "CWA_GITHUB_TEST_REPO_URL=${{ env.CWA_GITHUB_TEST_REPO_URL }}" >> "$GITHUB_OUTPUT"
6869 echo "CWA_GITHUB_TEST_REPO_BRANCH=${CWA_GITHUB_TEST_REPO_BRANCH:-${{ env.CWA_GITHUB_TEST_REPO_BRANCH }}}" >> "$GITHUB_OUTPUT"
6970
71+ - name : Checkout agent repository for commit date
72+ uses : actions/checkout@v3
73+ with :
74+ repository : aws/amazon-cloudwatch-agent
75+ fetch-depth : 0
76+ path : agent-repo
77+
78+ - name : Get commit date
79+ id : get-commit-date
80+ run : |
81+ cd agent-repo # Navigate to agent repo checkout
82+ echo "Extracting commit date from agent repository..."
83+
84+ # Get commit date as Unix timestamp, fallback to 0 for easier backfilling
85+ if [[ "${{ inputs.build_id }}" =~ ^[0-9a-f]{40}$ ]]; then
86+ # Full SHA - get date from git log
87+ echo "Full SHA detected: ${{ inputs.build_id }}"
88+ COMMIT_DATE=$(git log -1 --format=%ct ${{ inputs.build_id }} 2>/dev/null || echo "0")
89+ elif [[ "${{ inputs.build_id }}" =~ ^[0-9]+\.[0-9]+\.[0-9a-f]+$ ]]; then
90+ # Version format like 1.300057.1b1168 - extract SHA and get date
91+ SHA_PART=$(echo "${{ inputs.build_id }}" | sed 's/.*\.//')
92+ echo "Version format detected, extracted SHA: $SHA_PART"
93+ COMMIT_DATE=$(git log -1 --format=%ct --grep="$SHA_PART" 2>/dev/null || echo "0")
94+ else
95+ # Fallback to 0 for easier backfilling of historical data
96+ echo "Unknown format, using 0 for easier backfilling"
97+ COMMIT_DATE="0"
98+ fi
99+
100+ echo "commit_date=${COMMIT_DATE}" >> $GITHUB_OUTPUT
101+ echo "Retrieved commit date: ${COMMIT_DATE} for build_id: ${{ inputs.build_id }}"
102+
103+ if [[ "$COMMIT_DATE" != "0" ]]; then
104+ echo "SUCCESS: Found commit date ${COMMIT_DATE}"
105+ else
106+ echo "Using 0 - can be backfilled later with historical data"
107+ fi
108+
70109 - name : Echo test variables
71110 run : |
72111 echo "build_id: ${{ inputs.build_id }}"
73112 echo "CWA_GITHUB_TEST_REPO_NAME: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}"
74113 echo "CWA_GITHUB_TEST_REPO_URL: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_URL }}"
75114 echo "CWA_GITHUB_TEST_REPO_BRANCH: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}"
115+ echo "CWA_COMMIT_DATE: ${{ steps.get-commit-date.outputs.commit_date }}"
76116
77117 - uses : actions/checkout@v3
78118 with :
@@ -941,7 +981,7 @@ jobs:
941981 -var="test_dir=${{ matrix.arrays.test_dir }}"\
942982 -var="cwagent_image_repo=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_INTEGRATION_TEST_REPO }}" \
943983 -var="cwagent_image_tag=${{ inputs.build_id }}" \
944- -var="k8s_version=${{ matrix.arrays.k8s_version }}"; then
984+ -var="k8s_version=${{ matrix.arrays.k8sVersion }}"; then
945985 terraform destroy -auto-approve
946986 else
947987 terraform destroy -auto-approve && exit 1
@@ -1005,6 +1045,7 @@ jobs:
10051045 if terraform apply --auto-approve \
10061046 -var="ssh_key_value=${PRIVATE_KEY}" \
10071047 -var="cwa_github_sha=${{ inputs.build_id }}" \
1048+ -var="cwa_github_sha_date=${{ needs.OutputEnvVariables.outputs.CWA_COMMIT_DATE }}" \
10081049 -var="ami=${{ matrix.arrays.ami }}" \
10091050 -var="arc=${{ matrix.arrays.arc }}" \
10101051 -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \
@@ -1069,6 +1110,7 @@ jobs:
10691110 if terraform apply --auto-approve \
10701111 -var="ssh_key_value=${PRIVATE_KEY}" \
10711112 -var="cwa_github_sha=${{ inputs.build_id }}" \
1113+ -var="cwa_github_sha_date=${{ needs.OutputEnvVariables.outputs.CWA_COMMIT_DATE }}" \
10721114 -var="ami=${{ matrix.arrays.ami }}" \
10731115 -var="arc=${{ matrix.arrays.arc }}" \
10741116 -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \
0 commit comments