-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (44 loc) · 1.51 KB
/
build-docker-image.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
50
51
52
53
name: Build and Push Docker Image
on:
push:
branches:
- master # Adjust this as necessary
jobs:
condition_check:
runs-on: ubuntu-latest
outputs:
proceed: ${{ steps.check_condition.outputs.proceed }}
steps:
- id: check_condition
name: Check Repository Name Condition
run: |
echo "proceed=true" >> $GITHUB_OUTPUT
if [[ "${{ github.repository }}" =~ project[0-9]+- ]]; then
echo "This repository is an student repository, skipping docker build."
echo "proceed=false" >> $GITHUB_OUTPUT
fi
build-and-push:
needs: condition_check
if: needs.condition_check.outputs.proceed == 'true'
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
# Convert repository name to lowercase and set it as an output
- name: Convert repository name to lowercase
id: repo_name
run: echo "repo_name_lower=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
file: .devcontainer/Dockerfile
push: true
tags: ghcr.io/${{ env.repo_name_lower }}/python-devcontainer:latest