workflow report as artifacts config #6
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: Python application with GitHub Actions | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
make install | |
- name: Lint with pyLint | |
run: | | |
make lint | |
- name: Format code | |
run: | | |
make format | |
- name: Run tests | |
run: | | |
# Retrieve the API key from the secret | |
OPENAI_API_KEY=$OPENAI_API_KEY make test | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
- name: Generate Report | |
run: | | |
report_file="reports.md" | |
report_status="" | |
if [ $? -eq 0 ]; then | |
report_status="✅ All tests passed!" | |
else | |
report_status="❌ Some tests failed. Check the logs for details." | |
fi | |
report_date=$(date +"%Y/%m/%d") | |
report_time=$(date +"%H:%M") | |
report_timezone=$(date +"%z") | |
report_action="" | |
if [ "${{ github.event_name }}" == "push" ]; then | |
report_action="Push to main branch" | |
elif [ "${{ github.event_name }}" == "pull_request" ]; then | |
report_action="Pull request to main branch" | |
fi | |
echo "## Test Report" >> $report_file | |
echo "Report status: $report_status" >> $report_file | |
echo "Report Date: $report_date" >> $report_file | |
echo "Report Time: $report_time" >> $report_file | |
echo "Report Timezone: $report_timezone" >> $report_file | |
echo "Report Action: $report_action" >> $report_file | |
echo "" >> $report_file | |
# Commit and push the report file back to the repository | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add $report_file | |
git commit -m "Update test report [skip ci]" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.FLOW_TOKEN }} |