diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 47fdc18..ce9a6a4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,26 +6,46 @@ on: pull_request: branches: [ "main" ] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}-pr${{ github.event.pull_request.number }} + jobs: - # Run each jobs in container by use of shared Dockerfile + prepare-container: + runs-on: ubuntu-latest + steps: + - uses: docker/login-action@v3 + with: + registry: ${{ env.CONTAINER_REGISTRY } + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} build: + needs: prepare-container runs-on: ubuntu-latest + container: + image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 - - run: | - git clone https://github.com/vlang/v /opt/v --depth 1 - cd /opt/v - make - ./v symlink - run: make build - run: make run args=-help test: runs-on: ubuntu-latest + container: + image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 - - run: | - git clone https://github.com/vlang/v /opt/v --depth 1 - cd /opt/v - make - ./v symlink - run: make test