Skip to content

Commit

Permalink
ci: fix gha smells
Browse files Browse the repository at this point in the history
- Stop running workflows when there is a newer commit in branch
- Use commit hash instead of tags for action versions
- Use names for run steps
- Steps should only perform a single command
  • Loading branch information
ceddy4395 committed May 1, 2024
1 parent 49ce9c0 commit 8525fbb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
- uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
51 changes: 29 additions & 22 deletions .github/workflows/uwp-autoconvert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
branches:
- master

concurrency:
group: ${{github.workflow}} - ${{github.ref}}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UnoCheck_Version: '1.18.1'
Expand All @@ -23,7 +26,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
fetch-depth: 0

Expand All @@ -32,54 +35,58 @@ jobs:
(Get-Content global.json).replace("latestFeature", "disable") | Set-Content global.json
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3
with:
global-json-file: global.json

- name: Setup GitVersion
uses: gittools/actions/gitversion/[email protected]
uses: gittools/actions/gitversion/setup@31b3198b2de324472547fecec2c0f721b70c38e2 # v0.9.15
with:
versionSpec: '5.10.3'

- name: GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
uses: gittools/actions/gitversion/execute@31b3198b2de324472547fecec2c0f721b70c38e2 # v0.9.15
with:
useConfigFile: true
configFilePath: gitversion.yml

- name: setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: setup git username
run: git config user.name "GitHub Actions Bot"

- name: Setup git email
run: git config user.email "<>"

- name: Add msbuild to PATH
uses: microsoft/[email protected]
uses: microsoft/setup-msbuild@34cfbaee7f672c76950673338facd8a73f637506 # v1.1

- run: |
echo "JAVA_HOME=$env:JAVA_HOME_11_X64" >> $env:GITHUB_ENV
echo "JavaSdkDirectory=$env:JAVA_HOME_11_X64" >> $env:GITHUB_ENV
name: Select JDK 11
- run: echo "JAVA_HOME=$env:JAVA_HOME_11_X64" >> $env:GITHUB_ENV
name: Select JDK 11 (Java home)

- run: echo "JavaSdkDirectory=$env:JAVA_HOME_11_X64" >> $env:GITHUB_ENV
name: Select JDK 11 (Java sdk directory)

- run: |
& dotnet tool update --global uno.check --version $env:UnoCheck_Version --add-source https://api.nuget.org/v3/index.json
& uno-check -v --ci --non-interactive --fix --skip androidsdk --skip androidemulator --skip xcode --skip gtk3 --skip vswin --skip vsmac --manifest $env:UnoCheck_Manifest
name: Install .NET Workloads
- run: |
& uno-check -v --ci --non-interactive --fix --skip androidsdk --skip androidemulator --skip xcode --skip gtk3 --skip vswin --skip vsmac --manifest $env:UnoCheck_Manifest
name: Run uno-check
- name: Convert source tree to UWP
working-directory: \src\Uno.WinUIRevert
run: |
cd $env:GITHUB_WORKSPACE\src\Uno.WinUIRevert
dotnet run "$env:GITHUB_WORKSPACE"
- name: Run API Sync Tool
working-directory: \build
run: |
cd $env:GITHUB_WORKSPACE\build
msbuild Uno.UI.Build.csproj /v:m "/p:CombinedConfiguration=Release|AnyCPU" /m /t:RunAPISyncTool /bl
- name: Turn script debugging on
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: Set-PSDebug -Trace 1

- name: Commit to repository
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
Set-PSDebug -Trace 1
git add .
git commit -m "Update UWP Autoconvert from $env:GITHUB_SHA"
git push origin $env:GITHUB_REF_NAME`:generated/$env:GITHUB_REF_NAME/uwp-autoconvert -f
run: git commit -a -m "Update UWP Autoconvert from $env:GITHUB_SHA"
- name: Push to repository
run: git push origin $env:GITHUB_REF_NAME`:generated/$env:GITHUB_REF_NAME/uwp-autoconvert -f

0 comments on commit 8525fbb

Please sign in to comment.