make image tag unique #2
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: release docker image | |
on: | |
push: | |
branches: [ main ] | |
schedule: | |
- cron: '5 12 3 * *' # every 3rd at 12:05 | |
jobs: | |
build: | |
strategy: | |
matrix: | |
image: | |
- alpine | |
- debian | |
permissions: write-all | |
name: build ${{ matrix.image }} image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: build the image | |
run: | | |
docker build -f Dockerfile.${{ matrix.image }} -t tbi:${{ matrix.image }} . | |
- name: login to ghcr.io | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: push the image | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/tbi | |
VERSION=${{ matrix.image }}:${{ github.sha }} | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag tbi:${{ matrix.image }} $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION |