forked from openstack-k8s-operators/ci-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (42 loc) · 1.56 KB
/
build-and-push-client-container.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Build and Push Image
on: [ push ]
env:
IMAGE_NAME: cifmw-client
IMAGE_REGISTRY: quay.rdoproject.org/ci-framework
REGISTRY_USER: ${{ secrets.QUAY_RDO_CI_FRAMEWORK_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.QUAY_RDO_CI_FRAMEWORK_PASSWORD }}
jobs:
build:
name: Build and push image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
# Overriding the LATEST_TAG var allows us to track latest
# tags for other branches, "latest" won't move unless code
# is merged into the main branch.
- name: Set latest tag for non main branch
if: "${{ steps.branch-name.outputs.current_branch != 'main' }}"
run: |
echo "LATEST_TAG=${{ steps.branch-name.outputs.current_branch }}-latest" >> $GITHUB_ENV
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.LATEST_TAG }} ${{ github.sha }}
containerfiles: |
containerfiles/Containerfile.client
- name: Push To quay.rdoproject.org
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"