Add execution environment #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish Ansible Image | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- name: Install ansible-builder | |
run: pip install ansible-builder | |
- name: Build Ansible Image | |
run: ansible-builder build --tag kubespray-ee:${{ github.sha }} --container-runtime docker | |
- name: Tag image with PR name | |
if: github.event_name == 'pull_request' | |
run: docker tag kubespray-ee:${{ github.sha }} kubespray-ee:pr-${{ github.event.number }} | |
- name: Tag image with latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: docker tag kubespray-ee:${{ github.sha }} kubespray-ee:latest | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: downcase REPO | |
run: | | |
echo "OWNER=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV} | |
- name: Push Image to GitHub Container Registry | |
run: docker push -a ghcr.io/${{ env.OWNER }}/kubespray-ee:${{ github.sha }} |