feat(#14): import gitlab stuff #1
Workflow file for this run
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 CI Images | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
jobs: | ||
env: | ||
GITHUB_REGISTRY: ghcr.io | ||
GITLAB_REGISTRY: ${{ secrets.GITLAB_REGISTRY }} | ||
IMAGE_NAME: ${{ github.repository }} | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.GITHUB_REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Login to GitLab Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.GITLAB_REGISTRY }} | ||
username: ${{ secrets.GITLAB_USERNAME }} | ||
password: ${{ secrets.GITLAB_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
file: ./cpython-ci/Dockerfile | ||
push: true | ||
tags: | | ||
${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test | ||
${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test | ||
test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Pull Docker image | ||
run: docker pull ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test | ||
- name: Run tests | ||
run: | | ||
docker run ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test /usr/local/bin/test_pythons.py | ||
docker run ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test tox --version | ||
docker run ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test mypy --version | ||
docker run ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test pipx --version | ||
release: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.GITHUB_REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Login to GitLab Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.GITLAB_REGISTRY }} | ||
username: ${{ secrets.GITLAB_USERNAME }} | ||
password: ${{ secrets.GITLAB_TOKEN }} | ||
- name: Pull and re-tag Docker images | ||
run: | | ||
docker pull ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test | ||
docker tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:active | ||
docker tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:main | ||
docker tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:active | ||
docker tag ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-test ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:main | ||
- name: Push Docker images | ||
run: | | ||
docker push ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:active | ||
docker push ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:main | ||
docker push ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:active | ||
docker push ${{ env.GITLAB_REGISTRY }}/${{ env.IMAGE_NAME }}:main |