2021-09-13 00:00:23 +03:00
|
|
|
name: Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
2021-09-13 00:03:50 +03:00
|
|
|
- 'v[0-9]+.[0-9]+.[0-9]+[a-z]?'
|
2021-09-13 00:00:23 +03:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
docker-build:
|
|
|
|
runs-on: ubuntu-latest
|
2023-03-27 18:44:55 +03:00
|
|
|
env:
|
2023-12-18 19:09:47 +03:00
|
|
|
# Force docker to output the progress in plain
|
|
|
|
BUILDKIT_PROGRESS: plain
|
2023-03-27 18:44:55 +03:00
|
|
|
# vars.DOCKERHUB_REPO needs to be '<user>/<repo>', for example 'vaultwarden/web-vault'
|
|
|
|
# Check for Docker hub credentials in secrets
|
|
|
|
HAVE_DOCKERHUB_LOGIN: ${{ vars.DOCKERHUB_REPO != '' && secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
|
|
|
|
# vars.GHCR_REPO needs to be 'ghcr.io/<user>/<repo>'
|
|
|
|
# Check for Github credentials in secrets
|
|
|
|
HAVE_GHCR_LOGIN: ${{ vars.GHCR_REPO != '' && github.repository_owner != '' && secrets.GITHUB_TOKEN != '' }}
|
2021-09-13 00:00:23 +03:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-08-02 16:34:28 +03:00
|
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
2021-09-13 00:00:23 +03:00
|
|
|
|
|
|
|
# Determine Docker Tag
|
|
|
|
- name: Init Variables
|
|
|
|
id: vars
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
2023-03-27 18:44:55 +03:00
|
|
|
echo "DOCKER_TAG=${GITHUB_REF#refs/*/}" | tee -a "${GITHUB_OUTPUT}"
|
2021-09-13 00:00:23 +03:00
|
|
|
elif [[ "${{ github.ref }}" == refs/heads/* ]]; then
|
2023-03-27 18:44:55 +03:00
|
|
|
echo "DOCKER_TAG=testing" | tee -a "${GITHUB_OUTPUT}"
|
2021-09-13 00:00:23 +03:00
|
|
|
fi
|
2022-06-02 21:26:42 +03:00
|
|
|
|
2023-03-27 18:44:55 +03:00
|
|
|
# Login to Docker Hub
|
|
|
|
- name: Login to Docker Hub
|
2024-08-02 16:34:28 +03:00
|
|
|
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
|
2023-03-27 18:44:55 +03:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
if: ${{ env.HAVE_DOCKERHUB_LOGIN == 'true' }}
|
|
|
|
|
|
|
|
- name: Tags for DockerHub
|
|
|
|
if: ${{ env.HAVE_DOCKERHUB_LOGIN == 'true' }}
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "tags=${tags:+${tags},}${{ vars.DOCKERHUB_REPO }}:${{ steps.vars.outputs.DOCKER_TAG }}" \
|
|
|
|
| tee -a "${GITHUB_ENV}"
|
|
|
|
|
|
|
|
# Login to GitHub Container Registry
|
|
|
|
- name: Login to GitHub Container Registry
|
2024-08-02 16:34:28 +03:00
|
|
|
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
|
2023-03-27 18:44:55 +03:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
if: ${{ env.HAVE_GHCR_LOGIN == 'true' }}
|
|
|
|
|
|
|
|
- name: Tags for ghcr.io
|
|
|
|
if: ${{ env.HAVE_GHCR_LOGIN == 'true' }}
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "tags=${tags:+${tags},}${{ vars.GHCR_REPO }}:${{ steps.vars.outputs.DOCKER_TAG }}" \
|
|
|
|
| tee -a "${GITHUB_ENV}"
|
|
|
|
|
2021-09-13 00:00:23 +03:00
|
|
|
- name: Build and push
|
2024-08-02 16:34:28 +03:00
|
|
|
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6.5.0
|
2021-09-13 00:00:23 +03:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
2023-03-27 18:44:55 +03:00
|
|
|
tags: ${{ env.tags }}
|