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
# .github/workflows/reusable-workflow.yml | ||
name: Reusable Build | ||
on: | ||
workflow_call: | ||
inputs: | ||
working-folder: | ||
required: true | ||
type: string | ||
scripts-folder: | ||
required: true | ||
type: string | ||
secrets: | ||
GITHUB_TOKEN: | ||
required: true | ||
jobs: | ||
build-and-test: | ||
runs-on: [self-hosted, iconeditor] | ||
env: | ||
RelativePath: ${{ inputs.working-folder }} | ||
RelativePathScripts: ${{ inputs.scripts-folder }} | ||
steps: | ||
# Same steps you have now, except you read from the 'inputs' | ||
# rather than your vars.AgentWorkingFolder, etc. | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Get Build Revision | ||
id: get_revision | ||
shell: bash | ||
run: | | ||
... | ||
# Use $GITHUB_ENV instead of ::set-output (since set-output is deprecated). | ||
# E.g.: | ||
# echo "build_revision=$new_build_revision" >> $GITHUB_ENV | ||
- name: Set agent into development mode | ||
shell: pwsh | ||
working-directory: ${{ env.RelativePathScripts }} | ||
run: | | ||
.\Set_Development_Mode.ps1 -RelativePath "${{ env.RelativePath }}" | ||
- name: Test and Build | ||
shell: pwsh | ||
working-directory: ${{ env.RelativePathScripts }} | ||
env: | ||
build_id: ${{ env.build_id }} | ||
build_revision: ${{ env.build_revision }} | ||
build_version: ${{ env.build_version }} | ||
run: | | ||
.\Build.ps1 -RelativePath "${{ env.RelativePath }}" ` | ||
-AbsolutePathScripts "${{ env.RelativePathScripts }}" | ||
- name: Restore agent from development mode | ||
shell: pwsh | ||
working-directory: ${{ env.RelativePathScripts }} | ||
run: | | ||
.\RevertDevelopmentMode.ps1 -RelativePath "${{ env.RelativePath }}" | ||
- name: Commit and Push Build Counter | ||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: 'Increment build revision to ${{ env.build_revision }}' | ||
file_pattern: '.github/buildCounter.txt' |