Skip to content

Feature: Github Actions Pull Request #31

Feature: Github Actions Pull Request

Feature: Github Actions Pull Request #31

# Path: .github/workflows/codespaces.yml
name: Codespaces Image
on:
pull_request:
branches: ['main']
paths:
- Dockerfile
push:
branches: ['main']
paths:
- Dockerfile
env:
USER: thangbuiq
REGISTRY: ghcr.io
IMAGE_NAME: ubunchuu-truong-us/devcontainer:latest
jobs:
build-test-image:
name: Test
runs-on: ubuntu-22.04
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
build-and-push-image:
runs-on: ubuntu-22.04
if: github.event_name == 'push'
needs: [build-test-image]
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USER }}
password: ${{ secrets.TOKEN_GITHUB }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}