Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docker ci #19

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}