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: Docker Image CI | |
on: | |
push: | |
branches: [main] | |
env: | |
IMAGE_NAME: edgecontrol | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
cache: "pip" | |
cache-dependency-path: | | |
requirements.txt | |
requirements-dev.txt | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Install dev dependencies | |
run: pip install -r requirements-dev.txt | |
- name: Run linters | |
run: ./scripts/lint.sh | |
push: | |
needs: lint | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build image | |
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push image | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
VERSION=$(echo "${{ github.sha }}" | cut -c 1-7) | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker tag $IMAGE_NAME $IMAGE_ID:latest | |
docker push --all-tags $IMAGE_ID |