Running Jobs in a Container

We can run jobs in a container in the following way -

1. Running a job within a container

name: My CI
on:
  push:
    branches: [main]
jobs:
  container-job:
    runs-on: ubuntu-latest
    container:
      image: crazyuploader/minimal_ubuntu:latest
      env:
        IS_PRODUCTION: true

If no other options are specified, we can simply write -

jobs:
  container-job:
    runs-on: ubuntu-latest
    container: crazyuploader/minimal_ubuntu:latest

2. Defining credentials for a container registry

container:
  image: crazyuploader/private_container
  credentials:
    username: ${{ secrets.USERNAME }}
    password: ${{ secrets.PASSWORD }}

Reference: GitHub Actions - GitHub Docs

Last updated