Docker Build #817
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 Build | |
on: | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: '0 23 * * *' | |
jobs: | |
docker-build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
timeout-minutes: 90 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2.4.0 | |
- name: Get date for DB version | |
run: | | |
DB_VERSION="nightly-$(date '+%y%m%d')" | |
export DB_VERSION | |
echo "DB_VERSION=$DB_VERSION" >> "$GITHUB_ENV" | |
- name: Build Docker Image | |
run: | | |
export NO_CACHE="${{ github.ref == 'refs/heads/main' }}" | |
DB="$DB_VERSION" make docker-build | |
- name: Log in to registry | |
if: github.ref == 'refs/heads/main' | |
# This is where you will update the PAT to GITHUB_TOKEN | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push image | |
if: github.ref == 'refs/heads/main' | |
run: | | |
IMAGE_ID="ghcr.io/${{ github.repository_owner }}/idris2-pack" | |
# Change all uppercase to lowercase | |
IMAGE_ID="$(echo "$IMAGE_ID" | tr '[:upper:]' '[:lower:]')" | |
# Strip git ref prefix from version | |
echo IMAGE_ID="$IMAGE_ID" | |
echo DB_VERSION="$DB_VERSION" | |
docker tag "$IMAGE_ID:latest" "$IMAGE_ID:$DB_VERSION" | |
docker push "$IMAGE_ID:latest" | |
docker push "$IMAGE_ID:$DB_VERSION" |