Skip to content

Commit

Permalink
sc-89752 initial test
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesh-v3 committed Jan 29, 2024
1 parent 34f24e3 commit 6a0232f
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 30 deletions.
131 changes: 105 additions & 26 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,121 @@
name: docker-image

on:
push:
branches:
- main
tags:
- '*.*.*'
# on:
# pull_request:
# release:
# push:
# branches:
# - 'master'
schedule:
- cron: '0 1 * * 0'

env:
IMAGE_NAME: ansible-core
LATEST_OS: alpine
LATEST_VERSION: v2.13
DOCKER_CLI_VERSION: "20.10.14"
GOSU_VERSION: "1.14"

jobs:
build_push_before_python38:
runs-on: ubuntu-latest
strategy:
matrix:
os: [almalinux8, alpine, ubuntu]
version: [v2.11]
steps:
- name: Checkout
uses: actions/checkout@v3

build:
- name: Prepare
id: prep
run: |
cp requirements/${MATRIX_VERSION}/requirements.txt requirements/requirements.txt
TAGS="${IMAGE_NAME}:${MATRIX_VERSION}-${MATRIX_OS}"
if [[ "$MATRIX_OS" == "$LATEST_OS" ]]; then
TAGS="${TAGS},${IMAGE_NAME}:$MATRIX_VERSION"
elif [[ "$MATRIX_OS" == "almalinux8" && "$MATRIX_VERSION" == "v2.11" ]]; then
TAGS="${TAGS},${IMAGE_NAME}:latest-${MATRIX_OS}"
fi
echo "::set-output name=tags::${TAGS}"
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
env:
MATRIX_OS: ${{ matrix.os }}
MATRIX_VERSION: ${{ matrix.version }}

runs-on: ubuntu-latest
- name: Set up Docker Buildx
uses: docker/[email protected]

steps:
- uses: actions/checkout@v2
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and Push
uses: docker/[email protected]
with:
labels: |
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ matrix.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.name }}
build-args: |
docker_version=${{ env.DOCKER_CLI_VERSION }}
gosu_version=${{ env.GOSU_VERSION }}
tags: ${{ steps.prep.outputs.tags }}
context: .
file: ./Dockerfile.${{ matrix.os }}
push: ${{ endsWith(github.ref, '/main') }}

- name: Output Image Name
run: |
echo "Built and pushed the following image(s):"
echo ${{ steps.prep.outputs.tags }}
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/${{ steps.prep.outputs.tags }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=latest
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
docker tag ${{ steps.prep.outputs.tags }} $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
# build:

# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v2

- name: Build image
run: docker build --platform linux/amd64 -t myimage .
# - name: Build image
# run: docker build --platform linux/amd64 -t myimage .

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# - name: Log into registry
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
# - name: Push image
# run: |
# IMAGE_ID=ghcr.io/${{ github.repository }}

# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# # Change all uppercase to lowercase
# IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

VERSION=latest
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
# VERSION=latest
# if [[ $GITHUB_REF == refs/tags/* ]]; then
# VERSION=${GITHUB_REF#refs/tags/}
# fi

docker tag myimage $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
# docker tag myimage $IMAGE_ID:$VERSION
# docker push $IMAGE_ID:$VERSION
4 changes: 0 additions & 4 deletions Dockerfile → Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ RUN gem install bundler
RUN pip3 install jmespath
WORKDIR /mnt

RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
RUN apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
RUN apt-get -y update && sudo apt-get -y install packer

USER ansible-10000

CMD [ "ansible-playbook", "playbook.yml" ]

0 comments on commit 6a0232f

Please sign in to comment.