Skip to content

Align changes with the Repository Template #131

Align changes with the Repository Template

Align changes with the Repository Template #131

name: CI/CD Pull Request
# The total recommended execution time for the "CI/CD Pull Request" workflow is around 20 minutes.
on:
push:
branches:
- "main"
# pull_request:
# types: [opened, reopened]
jobs:
metadata:
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
build_datetime_local: ${{ steps.variables.outputs.build_datetime_local }}
build_datetime: ${{ steps.variables.outputs.build_datetime }}
build_timestamp: ${{ steps.variables.outputs.build_timestamp }}
build_epoch: ${{ steps.variables.outputs.build_epoch }}
golang_version: ${{ steps.variables.outputs.golang_version }}
version: ${{ steps.variables.outputs.version }}
does_pull_request_exist: ${{ steps.pr_exists.outputs.does_pull_request_exist }}
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Set CI/CD variables
id: variables
run: |
datetime=$(date -u +'%Y-%m-%dT%H:%M:%S%z')
echo "build_datetime_local=$(TZ=Europe/London date --date=$datetime +'%Y-%m-%dT%H:%M:%S%z')" >> $GITHUB_OUTPUT
echo "build_datetime=$datetime" >> $GITHUB_OUTPUT
echo "build_timestamp=$(date --date=$datetime -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
echo "build_epoch=$(date --date=$datetime -u +'%s')" >> $GITHUB_OUTPUT
echo "golang_version=$(grep golang .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
- name: Check if pull request exists for this branch
id: pr_exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch_name=${GITHUB_REF#refs/heads/}
echo "Current branch is '$branch_name'"
if gh pr list --head $branch_name | grep -q .; then
echo "Pull request exists"
echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT
else
echo "Pull request doesn't exist"
echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
fi
- name: List variables
run: |
export BUILD_DATETIME_LOCAL="${{ steps.variables.outputs.build_datetime_local }}"
export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}"
export BUILD_TIMESTAMP="${{ steps.variables.outputs.build_timestamp }}"
export BUILD_EPOCH="${{ steps.variables.outputs.build_epoch }}"
export VERSION="${{ steps.variables.outputs.version }}"
export GOLANG_VERSION="${{ steps.variables.outputs.golang_version }}"
export DOES_PULL_REQUEST_EXIST="${{ steps.pr_exists.outputs.does_pull_request_exist }}"
make list-variables
test-stage: # Recommended maximum execution time is 5 minutes
needs: [metadata] # ,commit-stage]
uses: ./.github/workflows/stage-2-test.yaml

Check failure on line 63 in .github/workflows/cicd-1-pull-request.yaml

View workflow run for this annotation

GitHub Actions / CI/CD Pull Request

Invalid workflow file

The workflow is not valid. .github/workflows/cicd-1-pull-request.yaml (Line: 63, Col: 11): Secret UPDATE_FROM_TEMPLATE_GH_APP_PK_CONTENT is required, but not provided while calling. .github/workflows/cicd-1-pull-request.yaml (Line: 69, Col: 39): Invalid secret, UPDATE_FROM_TEMPLATE_GH_APP_PK is not defined in the referenced workflow.
with:
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
golang_version: "${{ needs.metadata.outputs.golang_version }}"
secrets:
UPDATE_FROM_TEMPLATE_GH_APP_ID: "${{ secrets.UPDATE_FROM_TEMPLATE_GH_APP_ID }}"
UPDATE_FROM_TEMPLATE_GH_APP_PK: "${{ secrets.UPDATE_FROM_TEMPLATE_GH_APP_PK }}"
UPDATE_FROM_TEMPLATE_GH_APP_SK_ID: "${{ secrets.UPDATE_FROM_TEMPLATE_GH_APP_SK_ID }}"
UPDATE_FROM_TEMPLATE_GH_APP_SK_CONTENT: "${{ secrets.UPDATE_FROM_TEMPLATE_GH_APP_SK_CONTENT }}"
UPDATE_FROM_TEMPLATE_GH_APP_SK_PASSPHRASE: "${{ secrets.UPDATE_FROM_TEMPLATE_GH_APP_SK_PASSPHRASE }}"