Build image #7
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 image" | |
| on: | |
| [workflow_dispatch] | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| date: | |
| name: Get current date | |
| runs-on: ubuntu-latest | |
| outputs: | |
| date: ${{ steps.date.outputs.date }} | |
| tag: ${{ steps.date.outputs.tag }} | |
| steps: | |
| - name: Get current date | |
| id: date | |
| run: | | |
| echo "date=$(date --rfc-3339=seconds | sed 's/ /T/')" >> $GITHUB_OUTPUT | |
| echo "tag=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT | |
| build: | |
| name: Build and push image | |
| needs: date | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: 'ubuntu' | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push image for amd64/arm64 | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| file: ./Dockerfile | |
| push: true | |
| build-args: | | |
| IMAGE_BUILD_DATE=${{ needs.date.outputs.date }} | |
| labels: | | |
| org.opencontainers.image.ref.name=${{ github.ref }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.version=ubuntu | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/webtop:ubuntu | |
| ghcr.io/${{ github.repository_owner }}/webtop:ubuntu-${{ needs.date.outputs.tag }} | |
| ${{ vars.DOCKERHUB_USERNAME }}/webtop:ubuntu | |
| ${{ vars.DOCKERHUB_USERNAME }}/webtop:ubuntu-${{ needs.date.outputs.tag }} | |