Try vars #49
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
name: 'HW2 action' | ||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'HW2/**' | ||
- '.github/workflows/HW2.yml' | ||
permissions: | ||
actions: write | ||
contents: write | ||
jobs: | ||
build-and-run-job: | ||
env: | ||
homework_label: HW2 | ||
cmake_preset: linux-release | ||
cmake_build_preset: linux-build-release | ||
hw_path: ./HW2 | ||
build_folder: build | ||
release_folder: linux-release | ||
# Variables to ppopulate in "Initialize variables" step | ||
build_path: | ||
bin_path: | ||
build_path: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Initialize variables | ||
run: | | ||
echo "build_path=${{env.hw_path}}/${{env.build_folder}}" >> $GITHUB_ENV | ||
echo "bin_path=${{env.hw_path}}/${{env.build_folder}}/${{env.release_folder}}/bin" >> $GITHUB_ENV | ||
echo "deb_path=${{env.hw_path}}/${{env.build_folder}}/${{env.release_folder}}/deb" >> $GITHUB_ENV | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Update apt-get | ||
run: sudo apt-get update | ||
- name: Build ip_filter | ||
working-directory: ${{env.hw_path}} | ||
run: | | ||
cmake -DBuildTests=On --preset ${{ env.cmake_preset }} | ||
cmake --build --preset ${{ env.cmake_build_preset }} | ||
- name: Run tests | ||
working-directory: ${{ env.bin_path }} | ||
run: ./ip_read_operator_test | ||
- name: Check tests results | ||
if: '!success()' | ||
run: | | ||
gh run cancel ${{ github.run_id }} | ||
gh run watch ${{ github.run_id }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build package | ||
working-directory: ${{env.build_path}}/${{env.release_folder}} | ||
run: cpack -G DEB | ||
- name: Run ip_filter | ||
run: '[[ $(cat ${{env.hw_path}}/ip_filter.tsv | ${{ env.bin_path }}/ip_filter | md5sum) == "24e7a7b2270daee89c64d3ca5fb3da1a -" ]] && echo "MD5 are equal"' | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.homework_label }}_${{ github.run_number }} | ||
release_name: ${{ env.homework_label }} release ${{ github.run_number }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload package | ||
id: upload-package-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ env.deb_path }}/ip_filter-1.0.0-Linux.deb | ||
asset_name: ip_filter-1.0.0-Linux.deb | ||
asset_content_type: application/vnd.debian.binary-package | ||
- name: Upload packet | ||
id: upload-app-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ env.bin_path }}/ip_filter | ||
asset_name: ip_filter | ||
asset_content_type: application/octet-stream |