ci #998
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: ci | |
on: | |
schedule: | |
- cron: '0 10 * * *' # everyday at 10am | |
push: | |
branches: | |
- "main" | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- 'main' | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Log in to the GitHub Container registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker image | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: | | |
xtruder/nix-devcontainer | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=semver,pattern=v{{version}} | |
type=semver,pattern=v{{major}} | |
type=edge,branch=main | |
- name: Build and push docker image to dockerhub | |
uses: docker/build-push-action@v2 | |
with: | |
context: "./src" | |
file: ./src/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |