Skip to content

Update Workflows

Update Workflows #8

Workflow file for this run

name: Build Microzig
on:
push:
branches: [main]
paths:
- .github/**
- build.zig*
- tools/**
- core/**
- bsp/**
- examples/**
pull_request:
branches: [main]
paths:
- build.zig*
- tools/**
- core/**
- bsp/**
- examples/**
jobs:
build-microzig:
<<<<<<< HEAD

Check failure on line 24 in .github/workflows/build-microzig.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-microzig.yml

Invalid workflow file

You have an error in your yaml syntax on line 24
if: |
${{
( github.event_name == 'pull_request' && github.base_ref == 'main' )
|| github.ref_name == 'main'
}}
name: Build
uses: ./.github/workflows/build-base.yml
with:
zig-version: ${{ vars.MZ_TARGET_ZIG_VERSION }}
get-submodules: true
is-packaged: true
zig-args: -Doptimize=ReleaseSmall
secrets:
downloads-url: ${{ secrets.DOWNLOADS_URL }}
# If this is a push to main we want to create an automatic test against the
# zig-master branch. To do this, we need to create a PR and while we could
# just go directly from main to zig-master, this would mean that if the tests
# with zig-master fail, the main branch will also display the failure (this
# is because github action results are saved based on the commit). To solve
# that issue, we create a new branch with a new commit in it, then create
# the PR based on that.
#
# Creates the branch that we will use for the PR to zig-master
=======
if: ${{ ( github.event_name == 'pull_request' && github.base_ref == 'main' ) || github.ref_name == 'main' }}
name: Build
uses: ./.github/workflows/zig-build-base.yml
with:
zig-version: 0.13.0
get-submodules: true
is-packaged: true
artifact-output-paths: boxzer-out
secrets:
downloads-url: ${{ secrets.DOWNLOADS_URL }}
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)
create-branch:
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
name: Create Patch Branch
needs:
- build-microzig
runs-on: ubuntu-latest
outputs:
branch: master-patch/${{ github.sha }}
permissions:
contents: write
pull-requests: write
steps:
<<<<<<< HEAD
# First we checkout the repository
- uses: actions/checkout@v4
# Check if the branch exsits. This will be used in future steps to
# conditionally execute them.
=======
- uses: actions/checkout@v4
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)
- id: cbe
name: Check branch exists
# The list remote returns nothing if the branch does not exist.
# So, if there is nothing in the command output, it does not exist
run: |
<<<<<<< HEAD
if [[ -z "$(git ls-remote \
--heads origin master-patch/${{ github.sha }})" ]]; then
=======
if [[ -z "$(git ls-remote --heads origin master-patch/${{ github.sha }})" ]]; then
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)
echo "exists=false" >> "$GITHUB_OUTPUT"
else
echo "exists=true" >> "$GITHUB_OUTPUT"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
<<<<<<< HEAD
# If the branch doesn't already exist, we create a new one. We use the
# username and email of the last commit.
=======
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)
- name: Create Branch
if: steps.cbe.outputs.exists == 'false'
run: |
git config user.name "$(git log -1 --pretty=format:'%an')"
git config user.email "$(git log -1 --pretty=format:'%ae')"
git checkout -b "master-patch/${{ github.sha }}"
git push -u origin "master-patch/${{ github.sha }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
<<<<<<< HEAD
# Checkout to the new branch
=======
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)
- name: checkout
uses: actions/checkout@v4
with:
ref: master-patch/${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
<<<<<<< HEAD
# Create an empty commit that will be used to save the ci results
# against (For more details see "create-branch" comment)
=======
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)
- name: add-commit
run: |
git config user.name "$(git log -1 --pretty=format:'%an')"
git config user.email "$(git log -1 --pretty=format:'%ae')"
<<<<<<< HEAD
git commit \
--author "ZEG Github Action <>" \
-m "chore: commit for zig master build ci" \
--allow-empty
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Now that a branch exists, we can create our PR. To do this we will use the
# github command line tool.
create-pr:
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
name: Create Pull Request
runs-on: ubuntu-latest
needs: create-branch
permissions:
pull-requests: read
contents: read
steps:
- uses: actions/checkout@v4
# Check if the PR already exists, this will be used to conditionally
# create the PR.
=======
git commit --author "ZEG Github Action <>" -m "feat: added commit file" --allow-empty
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)
- id: cpe
name: check pr exists
# github actions pr only outputs when the query find something.
# So, if the output is empty, pr does not exist
run: |
<<<<<<< HEAD
gh pr list -B zig-master \
-H "${{ needs.create-branch.outputs.branch }}" 2> check-exists-out
if [[ -z "$(cat check-exists-out)" ]]; then
=======
gh pr list -B zig-master -H "master-patch/${{ github.sha }}" 2> check-pr-exists-output
if [[ -z "$(cat check-pr-exists-output)" ]]; then
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)
echo "exists=false" >> "$GITHUB_OUTPUT"
else
echo "exists=true" >> "$GITHUB_OUTPUT"
fi
<<<<<<< HEAD
cat check-exists-out
rm check-exists-out
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create the actual PR if it doesn't already exist
- name: create pull request,
if: steps.cpe.outputs.exists == 'false'
run: |
gh pr create -B zig-master -H master-patch/${{ github.sha }} \
--title 'Testing commit ${{ github.sha }} with zig master' \
--body 'Created by Github action'
env:
# We use a custom TOKEN to enable triggering other workflows.
# See: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow#triggering-a-workflow-from-a-workflow
GITHUB_TOKEN: ${{ secrets.PR_CREATE_TOKEN }}
=======
rm check-pr-exists-output
env:
GITHUB_TOKEN: ${{ secrets.PR_CREATE_PAT }}
- name: create pull request,
if: steps.cpe.outputs.exists == 'false'
run: |
gh pr create -B zig-master -H master-patch/${{ github.sha }} --title 'Testing commit ${{ github.sha }} with zig master' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.PR_CREATE_PAT }}
>>>>>>> ea386ec (ci: implement build pipeline and patch to zig master)