feat: ci for docker #1
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: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get Vars | |
id: get_vars | |
run: | | |
echo "ts=$(date +%s)" >> $GITHUB_OUTPUT | |
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT | |
- name: Docker meta | |
id: docker_meta | |
uses: crazy-max/ghaction-docker-meta@v1 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }}/api | |
tag-sha: true | |
tag-semver: | | |
{{version}} | |
{{major}}.{{minor}} | |
tag-custom: | | |
${{ steps.get_vars.outputs.branch }}-${{ steps.get_vars.outputs.sha }}-${{ steps.get_vars.outputs.ts }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Digital Ocean Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./src/ign-api | |
push: true | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_mata.outputs.labels }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |