57 lines
1.6 KiB
YAML
57 lines
1.6 KiB
YAML
# Copyright 2023 DigitalOcean
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
name: Docker Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
tags:
|
|
- '*'
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Set up Docker buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
- name: Build and push latest
|
|
if: github.ref == 'refs/heads/main'
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
tags: digitalocean/ceph_exporter:latest
|
|
|
|
- name: Get tag
|
|
id: get_tag
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
shell: bash
|
|
run: |
|
|
echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d/ -f3)
|
|
|
|
- name: Build and push tag
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
tags: digitalocean/ceph_exporter:${{ steps.get_tag.outputs.TAG_NAME }}
|