2022-11-15 22:49:39 +01:00
|
|
|
name: Build the Docker images and push them to Docker Hub
|
|
|
|
|
|
|
|
on:
|
|
|
|
# Only trigger the workflow when there is a new commit to the master branch
|
|
|
|
push:
|
|
|
|
branches: [ "master" ]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
deploy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2023-05-18 11:50:13 +02:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v3
|
2022-11-15 22:49:39 +01:00
|
|
|
|
2023-05-18 11:50:13 +02:00
|
|
|
- name: Set up QEMU (for ARM emulation)
|
|
|
|
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
2023-05-18 11:50:13 +02:00
|
|
|
- name: Build the Docker images and push
|
2023-05-18 11:50:13 +02:00
|
|
|
env:
|
|
|
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
|
|
run: |
|
2023-05-18 11:50:13 +02:00
|
|
|
# Initialize variables
|
2023-05-18 11:50:13 +02:00
|
|
|
DOCKER_IMG_TAG=`echo "${{ github.sha }}" | cut -c 1-7`
|
2023-05-18 11:50:13 +02:00
|
|
|
DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}
|
|
|
|
# Login
|
2023-05-18 11:50:13 +02:00
|
|
|
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
2023-05-18 11:50:13 +02:00
|
|
|
# Create the environment
|
|
|
|
sed -e '/^[[:space:]]*$/d' -e '/[#@]/d' -e 's/\(^[^=]*\)=\(.*\)/\1="\2"/' template.env > env.hcl
|
|
|
|
# Build and Push
|
|
|
|
DOCKER_IMG_TAG=$DOCKER_IMG_TAG DOCKER_USERNAME=$DOCKER_USERNAME docker buildx bake -f docker-bake.hcl -f env.hcl --push
|