Merge pull request #119 from cs50/detect-missing-file-ext #889
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
on: | |
- push | |
- workflow_dispatch | |
jobs: | |
build: | |
runs-on: ubuntu-latest-16-cores | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log into Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Log into GitHub Packages | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build (latest) | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
export VCS_REF=$(git rev-parse HEAD) | |
npm install -g @devcontainers/cli | |
devcontainer build --workspace-folder . --image-name cs50/codespace:${{ github.sha }} --image-name cs50/codespace:latest | |
- name: Push (latest) to GitHub Packages | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
docker tag cs50/codespace:${{ github.sha }} ghcr.io/cs50/codespace:${{ github.sha }} | |
docker tag cs50/codespace:latest ghcr.io/cs50/codespace:latest | |
docker push ghcr.io/cs50/codespace:${{ github.sha }} | |
docker push ghcr.io/cs50/codespace:latest | |
- name: Push to Docker Hub (latest) | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
docker push cs50/codespace:${{ github.sha }} | |
docker push cs50/codespace:latest | |
- name: Build (develop) | |
if: ${{ github.ref == 'refs/heads/develop' }} | |
run: | | |
export VCS_REF=$(git rev-parse HEAD) | |
npm install -g @devcontainers/cli | |
devcontainer build --workspace-folder . --image-name cs50/codespace:${{ github.sha }} --image-name cs50/codespace:develop | |
- name: Push (develop) to GitHub Packages | |
if: ${{ github.ref == 'refs/heads/develop' }} | |
run: | | |
docker tag cs50/codespace:${{ github.sha }} ghcr.io/cs50/codespace:develop | |
docker push ghcr.io/cs50/codespace:develop | |
- name: Push to Docker Hub (develop) | |
if: ${{ github.ref == 'refs/heads/develop' }} | |
run: | | |
docker push cs50/codespace:${{ github.sha }} | |
docker push cs50/codespace:develop | |
- name: Tag main as latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
try { | |
await github.rest.git.updateRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "tags/latest", | |
sha: context.sha, | |
force: true | |
}) | |
} catch (e) { | |
await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/latest", | |
sha: context.sha | |
}) | |
} |