Skip to content

Commit

Permalink
add docker ci (#19)
Browse files Browse the repository at this point in the history
* add docker ci

* update branch
  • Loading branch information
niqdev authored Aug 28, 2024
1 parent 0c9c1d3 commit ffd44aa
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: docker-ci

on:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

env:
DOCKER_REPOSITORY: edgelevel
DOCKER_IMAGE_NAME: lastpass-operator

jobs:
docker:
name: Docker
runs-on: ubuntu-latest
# makes sure it doesn't finish the minutes quota if stalls
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4

# extracts tag from ref, returns semver tag or sha suffix
- name: Get Docker tag
id: get-docker-tag
env:
GITHUB_REF: ${{ github.ref }}
COMMIT_SHA: ${{ github.sha }}
run: |
if [[ ${{ github.ref_type }} == "tag" ]]; then
echo "tag=${GITHUB_REF#refs/tags/v}" >> ${GITHUB_OUTPUT}
else
echo "tag=${COMMIT_SHA:0:7}" >> ${GITHUB_OUTPUT}
fi
- name: Output Docker tag
run: echo ${{ steps.get-docker-tag.outputs.tag }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# gh-actions-rw
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push [${{ env.DOCKER_IMAGE_NAME }}]
uses: docker/build-push-action@v6
with:
build-args: |
VERSION_COMMIT=${{ steps.get-docker-tag.outputs.tag }}
# if false it will only build
push: true
tags: |
${{ env.DOCKER_REPOSITORY }}/${{ env.DOCKER_IMAGE_NAME }}:latest
${{ env.DOCKER_REPOSITORY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.get-docker-tag.outputs.tag }}

0 comments on commit ffd44aa

Please sign in to comment.