Skip to content

Docker -- GHCR

Docker -- GHCR #4

Workflow file for this run

name: Docker -- GHCR
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'docker/**/*'
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
images:
- landing
- gitpod-fcc
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
- name: Log in to the GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
run: |
cd docker/${{ matrix.images }}
docker build . \
--tag ghcr.io/freecodecamp/${{ matrix.images }}:${{ github.sha }} \
--tag ghcr.io/freecodecamp/${{ matrix.images }}:latest
docker push --all-tags ghcr.io/freecodecamp/${{ matrix.images }}