Adding on github actions

This commit is contained in:
James Jones
2022-11-21 15:46:39 -05:00
parent fc5ba2b9b1
commit 53f9f1bba7

View File

@@ -1,4 +1,5 @@
name: Build podman-dind-like name: Build podman-dind-like
on: on:
push: push:
branches: branches:
@@ -6,7 +7,13 @@ on:
- feature/* - feature/*
- develop - develop
pull_request: pull_request:
branches: [ main ] branches:
- main
- develop
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
build: build:
@@ -18,27 +25,42 @@ jobs:
# Downloads a copy of the code in your repository before running CI tests # Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@v3 uses: actions/checkout@v3
# - name: Docker Login - name: Add on podman-docker for step compatibility
# uses: azure/docker-login@v1
# with:
# login-server: ghcr.io
# username: $GITHUB_ACTOR
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the Docker image
run: | run: |
if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then dnf install -y podman-docker
VERSION=$GITHUB_REF_NAME - name: Docker Login
else uses: azure/docker-login@v1
VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|/|-|g') with:
fi login-server: ${{ env.REGISTRY }}
podman build . --file Dockerfile --tag "ghcr.io/$IMAGE_NAME:$VERSION" username: ${{ github.actor }}
echo $REG_TOKEN | podman login ghcr.io -u ${GITHUB_ACTOR} --password-stdin password: ${{ secrets.GITHUB_TOKEN }}
podman push "ghcr.io/$IMAGE_NAME:$VERSION" - name: Extract metadata (tags, labels) for Docker
if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then id: meta
podman tag "ghcr.io/$IMAGE_NAME:$VERSION" "$IMAGE_NAME:latest" uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
podman push "ghcr.io/$IMAGE_NAME:latest" with:
fi images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
env: - name: Build and push Docker images
REG_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
# REG_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} with:
IMAGE_NAME: jamesjonesconsulting/podman-dind-like context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# - name: Build the Docker image
# run: |
# if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then
# VERSION=$GITHUB_REF_NAME
# else
# VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|/|-|g')
# fi
# podman build . --file Dockerfile --tag "ghcr.io/$IMAGE_NAME:$VERSION"
# echo $REG_TOKEN | podman login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
# podman push "ghcr.io/$IMAGE_NAME:$VERSION"
# if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then
# podman tag "ghcr.io/$IMAGE_NAME:$VERSION" "$IMAGE_NAME:latest"
# podman push "ghcr.io/$IMAGE_NAME:latest"
# fi
# env:
# REG_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # REG_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
# IMAGE_NAME: jamesjonesconsulting/podman-dind-like