61 lines
1.8 KiB
YAML
61 lines
1.8 KiB
YAML
name: Build, push and deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
builds:
|
|
runs-on: herobox-ubuntu-latest
|
|
|
|
steps:
|
|
- name: checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
# - name: set up docker cli
|
|
# uses: alpinelinux/docker-cli@v1
|
|
# with:
|
|
# docker-version: '20.10.7'
|
|
|
|
- name: install docker
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y docker.io
|
|
|
|
- name: set up docker buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: log in to docker hub
|
|
run: |
|
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin gitea.oio.cat
|
|
env:
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: build docker image
|
|
run: |
|
|
IMG_ID=$(date '+%Y%m%d-%H%M%S')-$(git rev-parse --short HEAD)
|
|
echo "1: "
|
|
echo $IMG_ID > IMG_ID.output
|
|
docker build -t albertabril:$IMG_ID .
|
|
|
|
- name: tag docker to latest
|
|
run: |
|
|
IMG_ID=$(cat ./IMG_ID.output) #ensure it is there
|
|
echo "2: "
|
|
echo $IMG_ID
|
|
# docker tag albertabril:$IMG_ID gitea.oio.cat/albert/albertabril:$IMG_ID
|
|
# docker tag albertabril:$IMG_ID gitea.oio.cat/albert/albertabril:latest
|
|
docker tag albertabril:$IMG_ID gitea.oio.cat/albert/ovh-followup:$IMG_ID
|
|
docker tag albertabril:$IMG_ID gitea.oio.cat/albert/ovh-followup:latest
|
|
|
|
- name: push docker images to gitea.oio.cat hub
|
|
run: |
|
|
IMG_ID=$(cat ./IMG_ID.output)
|
|
echo "3: " $IMG_ID
|
|
docker push gitea.oio.cat/albert/ovh-followup:$IMG_ID
|
|
docker push gitea.oio.cat/albert/ovh-followup:latest
|
|
|
|
|