1. A complete workflow #
Tests on two Python versions.
The file #
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: requirements-dev.txt
- run: pip install -r requirements-dev.txt
- run: pytest --junitxml=rapport-${{ matrix.python }}.xml
- uses: actions/upload-artifact@v7
if: always()
with:
name: rapport-${{ matrix.python }}
path: rapport-${{ matrix.python }}.xml
- run: echo "### Tests Python ${{ matrix.python }} réussis :white_check_mark:" >> "$GITHUB_STEP_SUMMARY"onsets triggers, withbranches,pathsandpaths-ignorefilters.concurrencycancels the previous run of the same branch;timeout-minutesbounds duration.setup-pythonhandles the pip cache itself;actions/cachecovers other cases.
Contexts #
2. Data between steps and jobs #
Outputs, environment, summary.
Outputs #
jobs:
version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.calc.outputs.tag }}
steps:
- id: calc
run: echo "tag=$(date +%Y.%m.%d)-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
build:
needs: version
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- run: echo "Version ${{ needs.version.outputs.tag }}"$GITHUB_OUTPUTpublishes a step output,$GITHUB_ENVa variable for following steps,$GITHUB_STEP_SUMMARYa Markdown summary shown on the run page.- The
success(),failure(),always(),cancelled()functions condition a step on the job state. - Service containers (
services: postgres:) provide a database for the duration of the job.
Watch out : Theset-outputandsave-statecommands are removed: use the$GITHUB_OUTPUTand$GITHUB_STATEfiles.
Commands to know #
Commands to know
gh run view --log-failed: log of failed stepsgh run download <id>: download artifactsgh run rerun --failed: rerun failed jobsgh cache list: cache entries
Sources #
Checked in November 2026: CI/CD platforms change every month, check versions and plans in the vendor's documentation.
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Writing a .gitlab-ci.yml: jobs, rules, cache and artifacts
Mastering .gitlab-ci.yml syntax: stages, jobs and images, rules and workflow, needs (DAG), cache ...
Reusing and securing GitHub Actions workflows
Industrializing GitHub Actions: reusable workflows, composite, JavaScript and Docker actions, lea...
GitHub Actions: concepts and how it works
Discover GitHub Actions: events, workflows, jobs, steps and actions, the Marketplace, hosted runn...
GitHub Actions runners: hosted, self-hosted and ARC
Choosing where workflows run: hosted runners and images, larger runners, self-hosted runners (ins...
End-to-end CI/CD (5/5): GitHub Actions, GitLab CI, Jenkins and Argo CD in practice
Compare and use CI/CD tools: GitHub Actions, GitLab CI, Jenkins, Argo CD and Flux; a complete pip...
Delivering with GitHub Actions: GHCR, environments, OIDC and attestations
Building and deploying with GitHub Actions: publishing an image to GitHub Container Registry with...
GitHub Actions best practices and troubleshooting
Running GitHub Actions: speeding up and cutting costs, debugging (debug logs, act locally, gh run...
End-to-end CI/CD (2/5): continuous integration, testing and quality
Succeed with continuous integration: the test pyramid, unit, integration, contract and end-to-end...
Azure YAML pipelines: stages, tasks, variables and templates
Writing Azure pipelines in YAML: trigger and pr triggers, stages, jobs and steps, versioned tasks...