To sheds more light on using GitHub Actions, this documentation breaks down the commands into simple bits: https://docs.github.com/en/actions
├── .github
│ ├── workflows
│ ├── ci.yaml
├── project base folder
│ ├── other folders
├── .env
├── package.json
├── package-lock.json
├── LICENSE
└── README.md
name: CI
on:
push:
branches: [main]
workflow_dispatch:
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/build-push-action@v3
with:
images: DOCKER_HUB_USERNAME/DOCKER_HUB_REPO_NAME
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
name: CI
on:
push:
branches: [main]
workflow_dispatch:
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/build-push-action@v3
with:
images: seunfunmi/node-application
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ./node-application
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}