Build Docker image - stable #18
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 Docker image - stable" | |
| on: | |
| schedule: | |
| - cron: "0 0 1 * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| get_date: | |
| name: Get current date in RFC 3339 | |
| runs-on: ubuntu-latest | |
| outputs: | |
| IMG_DATE: ${{ steps.date.outputs.IMG_DATE }} | |
| steps: | |
| - name: Get current date in RFC 3339 | |
| id: date | |
| run: | | |
| IMG_DATE=$(date --rfc-3339=seconds | sed 's/ /T/') | |
| echo "IMG_DATE=${IMG_DATE}" >> $GITHUB_OUTPUT | |
| echo "The date is $IMG_DATE" | |
| get_pkg_version: | |
| name: Get latest package version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| PKG_VER: ${{ steps.version.outputs.PKG_VER }} | |
| steps: | |
| - name: Override Ubuntu repos | |
| run: | | |
| echo -e "Package: *\nPin: origin packages.mozilla.org\nPin-Priority: 1000" | sudo tee -a /etc/apt/preferences.d/mozilla | |
| - name: Add Mozilla APT repo | |
| run: | | |
| sudo curl -vSLo \ | |
| /etc/apt/keyrings/packages.mozilla.org.asc \ | |
| https://packages.mozilla.org/apt/repo-signing-key.gpg | |
| echo \ | |
| "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" \ | |
| | sudo tee -a /etc/apt/sources.list.d/mozilla.list && \ | |
| sudo apt-get update -y | |
| - name: Get package version | |
| id: version | |
| run: | | |
| PKG_VER=$(apt list firefox | awk -F'[ /]' '/firefox/ {print $3}' | cut -d'~' -f1) | |
| echo "PKG_VER=${PKG_VER}" >> $GITHUB_OUTPUT | |
| echo "The package version is $PKG_VER" | |
| build_push: | |
| name: Build and push image | |
| runs-on: ubuntu-latest | |
| needs: [get_date, get_pkg_version] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: 'master' | |
| - 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.get_date.outputs.IMG_DATE }} | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/firefox:latest | |
| ghcr.io/${{ github.repository_owner }}/firefox:stable | |
| ghcr.io/${{ github.repository_owner }}/firefox:${{ needs.get_pkg_version.outputs.PKG_VER }} | |
| ${{ vars.DOCKERHUB_USERNAME }}/firefox:latest | |
| ${{ vars.DOCKERHUB_USERNAME }}/firefox:stable | |
| ${{ vars.DOCKERHUB_USERNAME }}/firefox:${{ needs.get_pkg_version.outputs.PKG_VER }} |