Build and Tag Image #81
This file contains hidden or 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: Build and Tag Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: "0 0 * * *" # once every 24 hours (UTC) | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| contents: write | |
| pull-requests: write | |
| repository-projects: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set timestamp tag | |
| id: tag | |
| run: | | |
| TAG=$(date +"%Y%m%d_%H%M%S") | |
| echo "TAG=$TAG" >> $GITHUB_ENV | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Docker image | |
| run: | | |
| IMAGE=ghcr.io/stratos-linux/stratos-base | |
| docker build \ | |
| -t $IMAGE:${TAG} \ | |
| -t $IMAGE:latest \ | |
| . | |
| # ghcr.io/${{ github.repository }} | |
| - name: Push Docker image | |
| run: | | |
| IMAGE=ghcr.io/stratos-linux/stratos-base | |
| docker push $IMAGE:${TAG} | |
| docker push $IMAGE:latest |