Skip to content

Merge pull request #26 from DeveloperMetrics/dependabot/github_action… #97

Merge pull request #26 from DeveloperMetrics/dependabot/github_action…

Merge pull request #26 from DeveloperMetrics/dependabot/github_action… #97

Workflow file for this run

name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs: # https://stackoverflow.com/questions/59175332/using-output-from-a-previous-job-in-a-new-one-in-a-github-action
Version: ${{ steps.gitversion.outputs.SemVer }}
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 #fetch-depth is needed for GitVersion
#Install and calculate the new version with GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.11.0
with:
versionSpec: 5.x
- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.11.0
id: gitversion # step id used as reference for output values
- name: Display GitVersion outputs
run: |
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
# checkout the code from this branch, and then test the action from here
test:
runs-on: ubuntu-latest
steps:
- name: checkout the code from this branch
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
#basic tests
- name: Test this repo
uses: ./ # the ./ runs the action.yml in this repo
with:
workflows: 'CI'
- name: Test elite repo with PAT Token, using last commit method (no dev time)
uses: ./
with:
workflows: 'Feature Flags CI/CD'
owner-repo: 'samsmithnz/SamsFeatureFlags'
commit-counting-method: 'last'
pat-token: "${{ secrets.PATTOKEN }}"
- name: Test elite repo with PAT Token, using first commit method (including dev time)
uses: ./
with:
workflows: 'Feature Flags CI/CD'
owner-repo: 'samsmithnz/SamsFeatureFlags'
commit-counting-method: 'first'
pat-token: "${{ secrets.PATTOKEN }}"
#authenication tests
- name: Test elite repo, multiple workflows, with PAT Token
uses: ./
with:
workflows: 'Feature Flags CI/CD,CodeQL'
owner-repo: 'samsmithnz/SamsFeatureFlags'
pat-token: "${{ secrets.PATTOKEN }}"
releaseAction:
runs-on: ubuntu-latest
needs:
- build
- test
if: github.ref == 'refs/heads/main'
steps:
- name: Display GitVersion outputs
run: |
echo "Version: ${{ needs.build.outputs.Version }}"
echo "CommitsSinceVersionSource: ${{ needs.build.outputs.CommitsSinceVersionSource }}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
if: needs.build.outputs.CommitsSinceVersionSource > 0 #Only create a release if there has been a commit/version change
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: "v${{ needs.build.outputs.Version }}"
release_name: "v${{ needs.build.outputs.Version }}"